]> granicus.if.org Git - clang/commitdiff
No longer emitting a PCH file when using -fsyntax-only on a header file. Fixes PR13343.
authorAaron Ballman <aaron@aaronballman.com>
Tue, 31 Jul 2012 01:21:00 +0000 (01:21 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Tue, 31 Jul 2012 01:21:00 +0000 (01:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161019 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp
lib/Driver/Tools.cpp
test/Driver/clang_f_opts.h [new file with mode: 0644]

index 5be60b8806fc4e80990df294c780a8aaf27e355e..671c0acaab22294b5ff2f13eb95c11176f13bc18 100644 (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);
index e13f709185f2f35fae2cfcb1662fb613de9f4b34..189ff5954a806bbdba0f1ef15fc4386877136445 100644 (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");
diff --git a/test/Driver/clang_f_opts.h b/test/Driver/clang_f_opts.h
new file mode 100644 (file)
index 0000000..e48d0cf
--- /dev/null
@@ -0,0 +1,2 @@
+// RUN: %clang -### -fsyntax-only %s 2>&1 | FileCheck %s
+// CHECK: -fsyntax-only