]> granicus.if.org Git - clang/commitdiff
Fix PCH/preprocess test to be more useful, and unbreak -E mode with implicit
authorDaniel Dunbar <daniel@zuster.org>
Thu, 12 Nov 2009 01:36:20 +0000 (01:36 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 12 Nov 2009 01:36:20 +0000 (01:36 +0000)
PCH, which I broke.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86921 91177308-0d34-0410-b5e6-96231b3b80d8

test/PCH/preprocess.c
tools/clang-cc/clang-cc.cpp

index bd91e5c118aed2a58d26a96ca1971ace045c4378..7a6c2c5a4e2bc88ff91eed24711194b75b259230 100644 (file)
@@ -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;
index 784b19e61c11f56d476285d9cb6227bf41f2316b..f6eec11c1c11472fa813f58513dccbcf968da57b 100644 (file)
@@ -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();
@@ -820,6 +820,18 @@ static void ProcessInputFile(const CompilerInvocation &CompOpts,
       return;
     }
 
+    // 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;
+  } 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