r264178 - clang-cl: Add more tests for the interaction of /FI and /Yc /Yu.
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 23 11:17:02 PDT 2016
Author: nico
Date: Wed Mar 23 13:17:02 2016
New Revision: 264178
URL: http://llvm.org/viewvc/llvm-project?rev=264178&view=rev
Log:
clang-cl: Add more tests for the interaction of /FI and /Yc /Yu.
Most things even work; see the included FIXMEs for things that need polishing.
Also don't warn about unused flags for the `/Yuh2.h /FIh1.h /FIh2.h`. The
common case is that the pch was built with `/Ych2.h /FIh1.h /FIh2.h`, so h1.h
is in the PCH, and we shouldn't warn about /FIh1.h not having an effect.
(If we wanted to get fancy, we could store the list of -include flags in the
pch and then check that it matches later on.)
Added:
cfe/trunk/test/Driver/Inputs/header0.h
cfe/trunk/test/Driver/Inputs/header4.h
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-pch-showincludes.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=264178&r1=264177&r2=264178&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Mar 23 13:17:02 2016
@@ -428,7 +428,7 @@ void Clang::AddPreprocessingOptions(Comp
// 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(Comp
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");
Added: cfe/trunk/test/Driver/Inputs/header0.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/header0.h?rev=264178&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/header4.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/header4.h?rev=264178&view=auto
==============================================================================
(empty)
Modified: cfe/trunk/test/Driver/cl-pch-showincludes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-showincludes.cpp?rev=264178&r1=264177&r2=264178&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-pch-showincludes.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-showincludes.cpp Wed Mar 23 13:17:02 2016
@@ -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}}
More information about the cfe-commits
mailing list