summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-09-30 16:53:47 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-09-30 16:53:47 +0000
commit2f23b414e9bc3005098b6379af36933896c58315 (patch)
tree73c863f94cb23a968e10950d35425c74352a16da /clang/lib/Driver/Tools.cpp
parente46564a4a827a1c1a18fb675544f7e7978ed9a1f (diff)
downloadbcm5719-llvm-2f23b414e9bc3005098b6379af36933896c58315.tar.gz
bcm5719-llvm-2f23b414e9bc3005098b6379af36933896c58315.zip
Driver: Ignore the found PCH file if its '-include' is not the first one.
llvm-svn: 115158
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 0701c5fa7b5..83ec814bc08 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -212,11 +212,15 @@ void Clang::AddPreprocessingOptions(const Driver &D,
// wonky, but we include looking for .gch so we can support seamless
// replacement into a build system already set up to be generating
// .gch files.
+ bool RenderedImplicitInclude = false;
for (arg_iterator it = Args.filtered_begin(options::OPT_clang_i_Group),
ie = Args.filtered_end(); it != ie; ++it) {
const Arg *A = it;
if (A->getOption().matches(options::OPT_include)) {
+ bool IsFirstImplicitInclude = !RenderedImplicitInclude;
+ RenderedImplicitInclude = true;
+
// Use PCH if the user requested it.
bool UsePCH = D.CCCUsePCH;
@@ -250,13 +254,19 @@ void Clang::AddPreprocessingOptions(const Driver &D,
}
if (FoundPCH || FoundPTH) {
- A->claim();
- if (UsePCH)
- CmdArgs.push_back("-include-pch");
- else
- CmdArgs.push_back("-include-pth");
- CmdArgs.push_back(Args.MakeArgString(P.str()));
- continue;
+ if (IsFirstImplicitInclude) {
+ A->claim();
+ if (UsePCH)
+ CmdArgs.push_back("-include-pch");
+ else
+ CmdArgs.push_back("-include-pth");
+ CmdArgs.push_back(Args.MakeArgString(P.str()));
+ continue;
+ } else {
+ // Ignore the PCH if not first on command line and emit warning.
+ D.Diag(clang::diag::warn_drv_pch_not_first_include)
+ << P.str() << A->getAsString(Args);
+ }
}
}
OpenPOWER on IntegriCloud