Driver: Ignore the found PCH file if its '-include' is not the first one.

llvm-svn: 115158
This commit is contained in:
Argyrios Kyrtzidis 2010-09-30 16:53:47 +00:00
parent e46564a4a8
commit 2f23b414e9
2 changed files with 19 additions and 7 deletions

View File

@ -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'">;
}

View File

@ -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);
}
}
}