[cfe-commits] r86921 - in /cfe/trunk: test/PCH/preprocess.c tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Wed Nov 11 17:36:20 PST 2009


Author: ddunbar
Date: Wed Nov 11 19:36:20 2009
New Revision: 86921

URL: http://llvm.org/viewvc/llvm-project?rev=86921&view=rev
Log:
Fix PCH/preprocess test to be more useful, and unbreak -E mode with implicit
PCH, which I broke.

Modified:
    cfe/trunk/test/PCH/preprocess.c
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/test/PCH/preprocess.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/preprocess.c?rev=86921&r1=86920&r2=86921&view=diff

==============================================================================
--- cfe/trunk/test/PCH/preprocess.c (original)
+++ cfe/trunk/test/PCH/preprocess.c Wed Nov 11 19:36:20 2009
@@ -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;

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86921&r1=86920&r2=86921&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Wed Nov 11 19:36:20 2009
@@ -783,7 +783,7 @@
 
   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 @@
     // 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.





More information about the cfe-commits mailing list