[cfe-commits] r44178 - in /cfe/trunk: Lex/Preprocessor.cpp test/Preprocessor/import_self.c

Chris Lattner sabre at nondot.org
Thu Nov 15 11:07:49 PST 2007


Author: lattner
Date: Thu Nov 15 13:07:47 2007
New Revision: 44178

URL: http://llvm.org/viewvc/llvm-project?rev=44178&view=rev
Log:
fix a bug Steve noticed, where a #import of the main file itself would fail.

Added:
    cfe/trunk/test/Preprocessor/import_self.c
Modified:
    cfe/trunk/Lex/Preprocessor.cpp

Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=44178&r1=44177&r2=44178&view=diff

==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Thu Nov 15 13:07:47 2007
@@ -416,7 +416,12 @@
   // Enter the main file source buffer.
   EnterSourceFile(MainFileID, 0);
   
-  
+  // Tell the header info that the main file was entered.  If the file is later
+  // #imported, it won't be re-entered.
+  if (const FileEntry *FE = 
+        SourceMgr.getFileEntryForLoc(SourceLocation::getFileLoc(MainFileID, 0)))
+    HeaderInfo.IncrementIncludeCount(FE);
+    
   std::vector<char> PrologFile;
   PrologFile.reserve(4080);
   

Added: cfe/trunk/test/Preprocessor/import_self.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/import_self.c?rev=44178&view=auto

==============================================================================
--- cfe/trunk/test/Preprocessor/import_self.c (added)
+++ cfe/trunk/test/Preprocessor/import_self.c Thu Nov 15 13:07:47 2007
@@ -0,0 +1,7 @@
+// RUN: clang -E -I. %s | grep BODY_OF_FILE | wc -l | grep 1
+
+// This #import should have no effect, as we're importing the current file.
+#import <import_self.c>
+
+BODY_OF_FILE
+





More information about the cfe-commits mailing list