diff options
| author | Erich Keane <erich.keane@intel.com> | 2018-08-17 13:43:39 +0000 |
|---|---|---|
| committer | Erich Keane <erich.keane@intel.com> | 2018-08-17 13:43:39 +0000 |
| commit | eaca3883089a1ebbdc9eb430933cd5981b413c99 (patch) | |
| tree | 622b4c124f93490c238049f55de0ef7b3b2f9932 | |
| parent | 734a04ea33064c790123f36051bd7cb2671a0054 (diff) | |
| download | bcm5719-llvm-eaca3883089a1ebbdc9eb430933cd5981b413c99.tar.gz bcm5719-llvm-eaca3883089a1ebbdc9eb430933cd5981b413c99.zip | |
Fix for bug 38508 - Don't do PCH processing when only generating preprocessor output
This clang-cl driver change removes the PCH options when we are only generating
preprocessed output. This is similar to the behavior of Y-.
Patch by: mikerice
Differential Revision: https://reviews.llvm.org/D50640
llvm-svn: 340025
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 7 | ||||
| -rw-r--r-- | clang/test/Driver/cl-pch.cpp | 21 | ||||
| -rw-r--r-- | clang/test/PCH/Inputs/pch-through-use3c.cpp | 2 | ||||
| -rw-r--r-- | clang/test/PCH/Inputs/pch-through3c.h | 1 | ||||
| -rw-r--r-- | clang/test/PCH/pch-through3c.cpp | 8 |
5 files changed, 36 insertions, 3 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 350ee0e39dc..6527c19b614 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3010,9 +3010,10 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args, 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); diff --git a/clang/test/Driver/cl-pch.cpp b/clang/test/Driver/cl-pch.cpp index 8521d3576a7..0103db93e1a 100644 --- a/clang/test/Driver/cl-pch.cpp +++ b/clang/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 diff --git a/clang/test/PCH/Inputs/pch-through-use3c.cpp b/clang/test/PCH/Inputs/pch-through-use3c.cpp new file mode 100644 index 00000000000..6102c514fba --- /dev/null +++ b/clang/test/PCH/Inputs/pch-through-use3c.cpp @@ -0,0 +1,2 @@ +int a = A; +// expected-no-diagnostics diff --git a/clang/test/PCH/Inputs/pch-through3c.h b/clang/test/PCH/Inputs/pch-through3c.h new file mode 100644 index 00000000000..ab2a05dbbf8 --- /dev/null +++ b/clang/test/PCH/Inputs/pch-through3c.h @@ -0,0 +1 @@ +#define A 1 diff --git a/clang/test/PCH/pch-through3c.cpp b/clang/test/PCH/pch-through3c.cpp new file mode 100644 index 00000000000..97b98c40598 --- /dev/null +++ b/clang/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 |

