[PATCH] D50640: Fix for bug 38508 - Don't do PCH processing when only generating preprocessor output

Erich Keane via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 17 06:44:27 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL340025: Fix for bug 38508 - Don't do PCH processing when only generating preprocessor… (authored by erichkeane, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50640?vs=161116&id=161229#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50640

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cl-pch.cpp
  cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp
  cfe/trunk/test/PCH/Inputs/pch-through3c.h
  cfe/trunk/test/PCH/pch-through3c.cpp


Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -3010,9 +3010,10 @@
     Args.eraseArg(options::OPT__SLASH_Yc);
     YcArg = nullptr;
   }
-  if (Args.hasArg(options::OPT__SLASH_Y_)) {
-    // /Y- disables all pch handling.  Rather than check for it everywhere,
-    // just remove clang-cl pch-related flags here.
+  if (FinalPhase == phases::Preprocess || Args.hasArg(options::OPT__SLASH_Y_)) {
+    // If only preprocessing or /Y- is used, all pch handling is disabled.
+    // Rather than check for it everywhere, just remove clang-cl pch-related
+    // flags here.
     Args.eraseArg(options::OPT__SLASH_Fp);
     Args.eraseArg(options::OPT__SLASH_Yc);
     Args.eraseArg(options::OPT__SLASH_Yu);
Index: cfe/trunk/test/Driver/cl-pch.cpp
===================================================================
--- cfe/trunk/test/Driver/cl-pch.cpp
+++ cfe/trunk/test/Driver/cl-pch.cpp
@@ -345,3 +345,24 @@
 // CHECK-NoSourceTP: pchfile.pch
 // CHECK-NoSourceTP: -x
 // CHECK-NoSourceTP: "c++"
+
+// If only preprocessing, PCH options are ignored.
+// RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-P %s
+// CHECK-YC-P-NOT: -emit-pch
+// CHECK-YC-P-NOT: -include-pch
+
+// RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-E %s
+// CHECK-YC-E-NOT: -emit-pch
+// CHECK-YC-E-NOT: -include-pch
+
+// RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU-P %s
+// CHECK-YU-P-NOT: -emit-pch
+// CHECK-YU-P-NOT: -include-pch
+
+// RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU-E %s
+// CHECK-YU-E-NOT: -emit-pch
+// CHECK-YU-E-NOT: -include-pch
Index: cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp
===================================================================
--- cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp
+++ cfe/trunk/test/PCH/Inputs/pch-through-use3c.cpp
@@ -0,0 +1,2 @@
+int a = A;
+// expected-no-diagnostics
Index: cfe/trunk/test/PCH/Inputs/pch-through3c.h
===================================================================
--- cfe/trunk/test/PCH/Inputs/pch-through3c.h
+++ cfe/trunk/test/PCH/Inputs/pch-through3c.h
@@ -0,0 +1 @@
+#define A 1
Index: cfe/trunk/test/PCH/pch-through3c.cpp
===================================================================
--- cfe/trunk/test/PCH/pch-through3c.cpp
+++ cfe/trunk/test/PCH/pch-through3c.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -I %S -emit-pch \
+// RUN:   -include Inputs/pch-through3c.h \
+// RUN:   -pch-through-header=Inputs/pch-through3c.h -o %t.3c %s
+
+// RUN: %clang_cc1 -verify -I %S -include-pch %t.3c \
+// RUN:   -include Inputs/pch-through3c.h \
+// RUN:   -pch-through-header=Inputs/pch-through3c.h \
+// RUN:   %S/Inputs/pch-through-use3c.cpp 2>&1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50640.161229.patch
Type: text/x-patch
Size: 3003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180817/1a4823cc/attachment.bin>


More information about the llvm-commits mailing list