summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/ClangTidy.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2016-08-23 14:13:31 +0000
committerAlexander Kornienko <alexfh@google.com>2016-08-23 14:13:31 +0000
commit42fd75ea86692a735bbdc49ece438a18794c040b (patch)
tree0aaa99a253deb16d76492919622bd9f074debe44 /clang-tools-extra/clang-tidy/ClangTidy.cpp
parenta4092104cb21ba98edf8ed48ce5640bb0725c406 (diff)
downloadbcm5719-llvm-42fd75ea86692a735bbdc49ece438a18794c040b.tar.gz
bcm5719-llvm-42fd75ea86692a735bbdc49ece438a18794c040b.zip
[clang-tidy] Fix the order of ExtraArgsBefore
Added tests for the relative order of -extra-arg(-before) and ExtraArgs(Before). llvm-svn: 279516
Diffstat (limited to 'clang-tools-extra/clang-tidy/ClangTidy.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidy.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index f2ad5b2b9a8..9eb3a9f3f37 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -426,10 +426,14 @@ runClangTidy(std::unique_ptr<ClangTidyOptionsProvider> 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());
+ CommandLineArguments AdjustedArgs = Args;
+ if (Opts.ExtraArgsBefore) {
+ auto I = AdjustedArgs.begin();
+ if (I != AdjustedArgs.end() && !StringRef(*I).startswith("-"))
+ ++I; // Skip compiler binary name, if it is there.
+ AdjustedArgs.insert(I, Opts.ExtraArgsBefore->begin(),
+ Opts.ExtraArgsBefore->end());
+ }
if (Opts.ExtraArgs)
AdjustedArgs.insert(AdjustedArgs.end(), Opts.ExtraArgs->begin(),
Opts.ExtraArgs->end());
OpenPOWER on IntegriCloud