summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/ClangTidy.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2015-11-09 16:28:11 +0000
committerAlexander Kornienko <alexfh@google.com>2015-11-09 16:28:11 +0000
commit64956b5e9afb2badbd91354aefba7bfdbd1652d4 (patch)
treea70d2ad42d321410c37a83d187269a36df33beba /clang-tools-extra/clang-tidy/ClangTidy.cpp
parent7dee82e729a166c302cab7db1bcfbd91844f664f (diff)
downloadbcm5719-llvm-64956b5e9afb2badbd91354aefba7bfdbd1652d4.tar.gz
bcm5719-llvm-64956b5e9afb2badbd91354aefba7bfdbd1652d4.zip
Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.
Summary: This patch depends on http://reviews.llvm.org/D14191 Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14192 llvm-svn: 252485
Diffstat (limited to 'clang-tools-extra/clang-tidy/ClangTidy.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidy.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index c637f6a3d84..f9d0da76c0e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -36,6 +36,7 @@
#include "clang/Tooling/Refactoring.h"
#include "clang/Tooling/ReplacementsYaml.h"
#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
@@ -376,6 +377,19 @@ runClangTidy(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
std::vector<ClangTidyError> *Errors, ProfileData *Profile) {
ClangTool Tool(Compilations, InputFiles);
clang::tidy::ClangTidyContext Context(std::move(OptionsProvider));
+ ArgumentsAdjuster PerFileExtraArgumentsInserter = [&Context](
+ const CommandLineArguments &Args, StringRef Filename) {
+ ClangTidyOptions Opts = Context.getOptionsForFile(Filename);
+ CommandLineArguments AdjustedArgs;
+ if (Opts.ExtraArgsBefore)
+ AdjustedArgs = *Opts.ExtraArgsBefore;
+ AdjustedArgs.insert(AdjustedArgs.begin(), Args.begin(), Args.end());
+ if (Opts.ExtraArgs)
+ AdjustedArgs.insert(AdjustedArgs.end(), Opts.ExtraArgs->begin(),
+ Opts.ExtraArgs->end());
+ return AdjustedArgs;
+ };
+ Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
if (Profile)
Context.setCheckProfileData(Profile);
OpenPOWER on IntegriCloud