summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Driver/Tools.cpp6
-rw-r--r--clang/test/Driver/Inputs/header0.h0
-rw-r--r--clang/test/Driver/Inputs/header4.h0
-rw-r--r--clang/test/Driver/cl-pch-showincludes.cpp29
4 files changed, 33 insertions, 2 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 9939ce1e315..b18ddd442db 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -428,7 +428,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
// FIXME: The code here assumes that /Yc and /Yu refer to the same file.
// cl.exe seems to support both flags with different values, but that
// seems strange (which flag does /Fp now refer to?), so don't implement
- // that until someone needs that.
+ // that until someone needs it.
int PchIndex = YcIndex != -1 ? YcIndex : YuIndex;
if (PchIndex != -1) {
if (isa<PrecompileJobAction>(JA)) {
@@ -438,8 +438,10 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
continue;
} else {
// When using the pch, skip all includes prior to the pch.
- if (AI < PchIndex)
+ if (AI < PchIndex) {
+ A->claim();
continue;
+ }
if (AI == PchIndex) {
A->claim();
CmdArgs.push_back("-include-pch");
diff --git a/clang/test/Driver/Inputs/header0.h b/clang/test/Driver/Inputs/header0.h
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/clang/test/Driver/Inputs/header0.h
diff --git a/clang/test/Driver/Inputs/header4.h b/clang/test/Driver/Inputs/header4.h
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/clang/test/Driver/Inputs/header4.h
diff --git a/clang/test/Driver/cl-pch-showincludes.cpp b/clang/test/Driver/cl-pch-showincludes.cpp
index 9ebe68899db..76b7cd1a25e 100644
--- a/clang/test/Driver/cl-pch-showincludes.cpp
+++ b/clang/test/Driver/cl-pch-showincludes.cpp
@@ -22,3 +22,32 @@
// CHECK-YU-NOT: Note: including file: {{.*header1.h}}
// CHECK-YU-NOT: Note: including file: {{.*header2.h}}
// CHECK-YU: Note: including file: {{[^ ]*header3.h}}
+
+// When not using pch at all, all the /FI files are printed.
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /FIheader2.h /c /Fo%t -- %s \
+// RUN: | FileCheck --strict-whitespace -check-prefix=CHECK-FI %s
+// CHECK-FI: Note: including file: {{[^ ]*header2.h}}
+// CHECK-FI: Note: including file: {{[^ ]*header1.h}}
+// CHECK-FI: Note: including file: {{[^ ]*header3.h}}
+
+// Also check that /FI arguments before the /Yc / /Yu flags are printed right.
+
+// /FI flags before the /Yc arg should be printed, /FI flags after it shouldn't.
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: | FileCheck --strict-whitespace -check-prefix=CHECK-YCFI %s
+// FIXME: The order of the first two lines here must be reversed:
+// CHECK-YCFI: Note: including file: {{[^ ]*header2.h}}
+// CHECK-YCFI: Note: including file: {{[^ ]*header0.h}}
+// FIXME: header1.h should be indented one more:
+// CHECK-YCFI: Note: including file: {{[^ ]*header1.h}}
+// CHECK-YCFI: Note: including file: {{[^ ]*header4.h}}
+// CHECK-YCFI: Note: including file: {{[^ ]*header3.h}}
+
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN: | FileCheck --strict-whitespace -check-prefix=CHECK-YUFI %s
+// CHECK-YUFI-NOT: Note: including file: {{.*pch}}
+// CHECK-YUFI-NOT: Note: including file: {{.*header0.h}}
+// CHECK-YUFI-NOT: Note: including file: {{.*header2.h}}
+// CHECK-YUFI-NOT: Note: including file: {{.*header1.h}}
+// CHECK-YUFI: Note: including file: {{[^ ]*header4.h}}
+// CHECK-YUFI: Note: including file: {{[^ ]*header3.h}}
OpenPOWER on IntegriCloud