[cfe-commits] r129514 - /cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Thu Apr 14 07:07:45 PDT 2011


Author: cornedbee
Date: Thu Apr 14 09:07:45 2011
New Revision: 129514

URL: http://llvm.org/viewvc/llvm-project?rev=129514&view=rev
Log:
Fix -H. It was pretty broken.

Modified:
    cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp

Modified: cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp?rev=129514&r1=129513&r2=129514&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp (original)
+++ cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp Thu Apr 14 09:07:45 2011
@@ -82,15 +82,18 @@
   // Adjust the current include depth.
   if (Reason == PPCallbacks::EnterFile) {
     ++CurrentIncludeDepth;
-  } else {
+  } else if (Reason == PPCallbacks::ExitFile) {
     if (CurrentIncludeDepth)
       --CurrentIncludeDepth;
 
     // We track when we are done with the predefines by watching for the first
-    // place where we drop back to a nesting depth of 0.
-    if (CurrentIncludeDepth == 0 && !HasProcessedPredefines)
+    // place where we drop back to a nesting depth of 1.
+    if (CurrentIncludeDepth == 1 && !HasProcessedPredefines)
       HasProcessedPredefines = true;
-  }
+
+    return;
+  } else
+    return;
 
   // Show the header if we are (a) past the predefines, or (b) showing all
   // headers and in the predefines at a depth past the initial file and command
@@ -107,7 +110,8 @@
 
     llvm::SmallString<256> Msg;
     if (ShowDepth) {
-      for (unsigned i = 0; i != CurrentIncludeDepth; ++i)
+      // The main source file is at depth 1, so skip one dot.
+      for (unsigned i = 1; i != CurrentIncludeDepth; ++i)
         Msg += '.';
       Msg += ' ';
     }





More information about the cfe-commits mailing list