aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-12 01:36:20 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-12 01:36:20 +0000
commit1ea52949b2852e88af4201cd46fe89f9af46220d (patch)
tree96b24786ef74df1668d2850edfe4334a2265a1ce
parentab71ff5cbaf6a4ab1df32221afbb0186c6fbbf0e (diff)
Fix PCH/preprocess test to be more useful, and unbreak -E mode with implicit
PCH, which I broke. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86921 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/PCH/preprocess.c9
-rw-r--r--tools/clang-cc/clang-cc.cpp14
2 files changed, 19 insertions, 4 deletions
diff --git a/test/PCH/preprocess.c b/test/PCH/preprocess.c
index bd91e5c118..7a6c2c5a4e 100644
--- a/test/PCH/preprocess.c
+++ b/test/PCH/preprocess.c
@@ -1,5 +1,8 @@
+// Check that -E mode is invariant when using an implicit PCH.
+
+// RUN: clang-cc -include %S/preprocess.h -E -o %t.orig %s
// RUN: clang-cc -emit-pch -o %t %S/preprocess.h
-// RUN: clang-cc -include-pch %t -E -o - %s | grep -c "a_typedef" | count 1
-#include "preprocess.h"
+// RUN: clang-cc -include-pch %t -E -o %t.from_pch %s
+// RUN: diff %t.orig %t.from_pch
-int a_value;
+a_typedef a_value;
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 784b19e61c..f6eec11c1c 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -783,7 +783,7 @@ static void ProcessInputFile(const CompilerInvocation &CompOpts,
const std::string &ImplicitPCHInclude =
CompOpts.getPreprocessorOpts().getImplicitPCHInclude();
- if (!ImplicitPCHInclude.empty()) {
+ if (Consumer && !ImplicitPCHInclude.empty()) {
// If the user specified -isysroot, it will be used for relocatable PCH
// files.
const char *isysrootPCH = CompOpts.getHeaderSearchOpts().Sysroot.c_str();
@@ -826,6 +826,18 @@ static void ProcessInputFile(const CompilerInvocation &CompOpts,
// the source location entries for the PCH file.
if (InitializeSourceManager(PP, InFile))
return;
+ } else if (!ImplicitPCHInclude.empty()) {
+ // If we have an implicit PCH, the source manager initialization was
+ // delayed, do it now.
+ //
+ // FIXME: Clean this up.
+
+ // Finish preprocessor initialization. We do this now (rather
+ // than earlier) because this initialization creates new source
+ // location entries in the source manager, which must come after
+ // the source location entries for the PCH file.
+ if (InitializeSourceManager(PP, InFile))
+ return;
}
// If we have an ASTConsumer, run the parser with it.