aboutsummaryrefslogtreecommitdiff
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
commit990142a23e41392ef7c0f14db4c0fcac67311cdf (patch)
tree6d0bce0ec1bd9ba74bbb5bb3edea9fa3b6a84e4d
parent138d6a6890c171068ac60430431eaadb3fcef9ab (diff)
Driver: Ignore the found PCH file if its '-include' is not the first one.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115158 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticDriverKinds.td2
-rw-r--r--lib/Driver/Tools.cpp24
2 files changed, 19 insertions, 7 deletions
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td
index b6e89bd78b..748a3db0c4 100644
--- a/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/include/clang/Basic/DiagnosticDriverKinds.td
@@ -102,5 +102,7 @@ def warn_drv_treating_input_as_cxx : Warning<
InGroup<Deprecated>;
def warn_drv_objc_gc_unsupported : Warning<
"Objective-C garbage collection is not supported on this platform, ignoring '%0'">;
+def warn_drv_pch_not_first_include : Warning<
+ "precompiled header '%0' was ignored because '%1' is not first '-include'">;
}
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 0701c5fa7b..83ec814bc0 100644
--- a/lib/Driver/Tools.cpp
+++ b/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);
+ }
}
}