[cfe-commits] r84197 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/cxx-pth.cpp
Daniel Dunbar
daniel at zuster.org
Thu Oct 15 13:02:47 PDT 2009
Author: ddunbar
Date: Thu Oct 15 15:02:44 2009
New Revision: 84197
URL: http://llvm.org/viewvc/llvm-project?rev=84197&view=rev
Log:
Driver: Default to using PTH for C++ precompiled header support, PCH for C++
isn't implemented yet.
- <rdar://problem/7297571> Clang should use pretokenized headers for C++ PCH
files
Added:
cfe/trunk/test/Driver/cxx-pth.cpp
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=84197&r1=84196&r2=84197&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct 15 15:02:44 2009
@@ -142,10 +142,15 @@
continue;
if (A->getOption().matches(options::OPT_include)) {
+ // Use PCH if the user requested it, except for C++ (for now).
+ bool UsePCH = D.CCCUsePCH;
+ if (types::isCXX(Inputs[0].getType()))
+ UsePCH = false;
+
bool FoundPTH = false;
bool FoundPCH = false;
llvm::sys::Path P(A->getValue(Args));
- if (D.CCCUsePCH) {
+ if (UsePCH) {
P.appendSuffix("pch");
if (P.exists())
FoundPCH = true;
@@ -164,8 +169,8 @@
if (!FoundPCH && !FoundPTH) {
P.appendSuffix("gch");
if (P.exists()) {
- FoundPCH = D.CCCUsePCH;
- FoundPTH = !D.CCCUsePCH;
+ FoundPCH = UsePCH;
+ FoundPTH = !UsePCH;
}
else
P.eraseSuffix();
@@ -173,7 +178,7 @@
if (FoundPCH || FoundPTH) {
A->claim();
- if (D.CCCUsePCH)
+ if (UsePCH)
CmdArgs.push_back("-include-pch");
else
CmdArgs.push_back("-include-pth");
@@ -528,7 +533,12 @@
else
CmdArgs.push_back("-E");
} else if (isa<PrecompileJobAction>(JA)) {
- if (D.CCCUsePCH)
+ // Use PCH if the user requested it, except for C++ (for now).
+ bool UsePCH = D.CCCUsePCH;
+ if (types::isCXX(Inputs[0].getType()))
+ UsePCH = false;
+
+ if (UsePCH)
CmdArgs.push_back("-emit-pch");
else
CmdArgs.push_back("-emit-pth");
Added: cfe/trunk/test/Driver/cxx-pth.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cxx-pth.cpp?rev=84197&view=auto
==============================================================================
--- cfe/trunk/test/Driver/cxx-pth.cpp (added)
+++ cfe/trunk/test/Driver/cxx-pth.cpp Thu Oct 15 15:02:44 2009
@@ -0,0 +1,12 @@
+// Test forced PTH for CXX support.
+
+// RUN: clang -x c++-header %s -### 2> %t.log &&
+// RUN: FileCheck -check-prefix EMIT -input-file %t.log %s &&
+
+// EMIT: "{{.*}}/clang-cc{{.*}}" {{.*}} "-emit-pth" "{{.*}}.cpp.gch" "-x" "c++-header" "{{.*}}.cpp"
+
+// RUN: touch %t.h.gch &&
+// RUN: clang -E -include %t.h %s -### 2> %t.log &&
+// RUN: FileCheck -check-prefix USE -input-file %t.log %s
+
+// USE: "{{.*}}/clang-cc{{.*}}" {{.*}}"-include-pth" "{{.*}}.h.gch" {{.*}}"-x" "c++" "{{.*}}.cpp"
More information about the cfe-commits
mailing list