summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2014-10-28 22:16:13 +0000
committerAlexander Kornienko <alexfh@google.com>2014-10-28 22:16:13 +0000
commit37f7abe4244c2c532b5e9545bcae93847e36264c (patch)
tree50431998ca032c2e6a9f7121062dcc4298952423 /clang-tools-extra/clang-tidy
parent349847d02a00017225b34b35eeb9dceb730d08b8 (diff)
downloadbcm5719-llvm-37f7abe4244c2c532b5e9545bcae93847e36264c.tar.gz
bcm5719-llvm-37f7abe4244c2c532b5e9545bcae93847e36264c.zip
[clang-tidy] Added -system-headers option.
Added -system-headers option to allow display of warnings from system headers. This is needed for testing libcxx, for example. llvm-svn: 220826
Diffstat (limited to 'clang-tools-extra/clang-tidy')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyOptions.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyOptions.h3
-rw-r--r--clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp7
4 files changed, 15 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 38c99ef1488..06e0e3f3903 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -367,7 +367,8 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location) {
}
const SourceManager &Sources = Diags->getSourceManager();
- if (Sources.isInSystemHeader(Location))
+ if (!*Context.getOptions().SystemHeaders &&
+ Sources.isInSystemHeader(Location))
return;
// FIXME: We start with a conservative approach here, but the actual type of
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 6a3aaebc13a..acdcb4d10dc 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -101,6 +101,7 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
ClangTidyOptions Options;
Options.Checks = "";
Options.HeaderFilterRegex = "";
+ Options.SystemHeaders = false;
Options.AnalyzeTemporaryDtors = false;
Options.User = llvm::None;
for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
@@ -122,6 +123,8 @@ ClangTidyOptions::mergeWith(const ClangTidyOptions &Other) const {
if (Other.HeaderFilterRegex)
Result.HeaderFilterRegex = Other.HeaderFilterRegex;
+ if (Other.SystemHeaders)
+ Result.SystemHeaders = Other.SystemHeaders;
if (Other.AnalyzeTemporaryDtors)
Result.AnalyzeTemporaryDtors = Other.AnalyzeTemporaryDtors;
if (Other.User)
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index 8a89c59613c..52adcae7fe0 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -66,6 +66,9 @@ struct ClangTidyOptions {
/// main files will always be displayed.
llvm::Optional<std::string> HeaderFilterRegex;
+ /// \brief Output warnings from system headers matching \c HeaderFilterRegex.
+ llvm::Optional<bool> SystemHeaders;
+
/// \brief Turns on temporary destructor-based analysis.
llvm::Optional<bool> AnalyzeTemporaryDtors;
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 01de2e0902d..a925a74de60 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -63,6 +63,10 @@ HeaderFilter("header-filter",
".clang-tidy file."),
cl::init(""), cl::cat(ClangTidyCategory));
+static cl::opt<bool>
+ SystemHeaders("system-headers",
+ cl::desc("Display the errors from system headers"),
+ cl::init(false), cl::cat(ClangTidyCategory));
static cl::opt<std::string>
LineFilter("line-filter",
cl::desc("List of files with line ranges to filter the\n"
@@ -198,6 +202,7 @@ std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider() {
ClangTidyOptions DefaultOptions;
DefaultOptions.Checks = DefaultChecks;
DefaultOptions.HeaderFilterRegex = HeaderFilter;
+ DefaultOptions.SystemHeaders = SystemHeaders;
DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
// USERNAME is used on Windows.
@@ -209,6 +214,8 @@ std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider() {
OverrideOptions.Checks = Checks;
if (HeaderFilter.getNumOccurrences() > 0)
OverrideOptions.HeaderFilterRegex = HeaderFilter;
+ if (SystemHeaders.getNumOccurrences() > 0)
+ OverrideOptions.SystemHeaders = SystemHeaders;
if (AnalyzeTemporaryDtors.getNumOccurrences() > 0)
OverrideOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
OpenPOWER on IntegriCloud