From: Aaron Ballman Date: Tue, 31 Jul 2012 01:21:00 +0000 (+0000) Subject: No longer emitting a PCH file when using -fsyntax-only on a header file. Fixes PR13343. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=761322b3bdea727de087dcdf355fee689f5b8358;p=clang No longer emitting a PCH file when using -fsyntax-only on a header file. Fixes PR13343. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161019 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 5be60b8806..671c0acaab 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -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); diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index e13f709185..189ff5954a 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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"); diff --git a/test/Driver/clang_f_opts.h b/test/Driver/clang_f_opts.h new file mode 100644 index 0000000000..e48d0cfc7c --- /dev/null +++ b/test/Driver/clang_f_opts.h @@ -0,0 +1,2 @@ +// RUN: %clang -### -fsyntax-only %s 2>&1 | FileCheck %s +// CHECK: -fsyntax-only