No longer emitting a PCH file when using -fsyntax-only on a header file. Fixes PR13343.

llvm-svn: 161019
This commit is contained in:
Aaron Ballman 2012-07-31 01:21:00 +00:00
parent 2b6a0dfd4c
commit 1f10cc5eb4
3 changed files with 13 additions and 3 deletions

View File

@ -1210,8 +1210,14 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
}
return new PreprocessJobAction(Input, OutputTy);
}
case phases::Precompile:
return new PrecompileJobAction(Input, types::TY_PCH);
case phases::Precompile: {
types::ID OutputTy = types::TY_PCH;
if (Args.hasArg(options::OPT_fsyntax_only)) {
// Syntax checks should not emit a PCH file
OutputTy = types::TY_Nothing;
}
return new PrecompileJobAction(Input, OutputTy);
}
case phases::Compile: {
if (Args.hasArg(options::OPT_fsyntax_only)) {
return new CompileJobAction(Input, types::TY_Nothing);

View File

@ -1537,7 +1537,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Use PCH if the user requested it.
bool UsePCH = D.CCCUsePCH;
if (UsePCH)
if (JA.getType() == types::TY_Nothing)
CmdArgs.push_back("-fsyntax-only");
else if (UsePCH)
CmdArgs.push_back("-emit-pch");
else
CmdArgs.push_back("-emit-pth");

View File

@ -0,0 +1,2 @@
// RUN: %clang -### -fsyntax-only %s 2>&1 | FileCheck %s
// CHECK: -fsyntax-only