aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-10-15 20:02:44 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-10-15 20:02:44 +0000
commit0ebd9321ba380471010341f24c874f46f56e7581 (patch)
treefd286f29054865ab6c86322a70e5bf5b131b5fa5
parent583f33b8a9227bace1a77a15404b4c64dc619d69 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84197 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Driver/Tools.cpp20
-rw-r--r--test/Driver/cxx-pth.cpp12
2 files changed, 27 insertions, 5 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 37fe980be2..2a9ff8f676 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -142,10 +142,15 @@ void Clang::AddPreprocessingOptions(const Driver &D,
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 @@ void Clang::AddPreprocessingOptions(const Driver &D,
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 @@ void Clang::AddPreprocessingOptions(const Driver &D,
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 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
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");
diff --git a/test/Driver/cxx-pth.cpp b/test/Driver/cxx-pth.cpp
new file mode 100644
index 0000000000..a06a257538
--- /dev/null
+++ b/test/Driver/cxx-pth.cpp
@@ -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"