[cfe-commits] r38630 - in /cfe/cfe/trunk: Lex/Lexer.cpp include/clang/Lex/Lexer.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:23:21 PDT 2007


Author: sabre
Date: Wed Jul 11 11:23:21 2007
New Revision: 38630

URL: http://llvm.org/viewvc/llvm-project?rev=38630&view=rev
Log:
Add support to track the real top-level file.

Modified:
    cfe/cfe/trunk/Lex/Lexer.cpp
    cfe/cfe/trunk/include/clang/Lex/Lexer.h

Modified: cfe/cfe/trunk/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Lexer.cpp?rev=38630&r1=38629&r2=38630&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Lexer.cpp (original)
+++ cfe/cfe/trunk/Lex/Lexer.cpp Wed Jul 11 11:23:21 2007
@@ -43,6 +43,7 @@
     BufferEnd(BufEnd ? BufEnd : File->getBufferEnd()),
     InputFile(File), CurFileID(fileid), PP(pp), Features(PP.getLangOptions()) {
   Is_PragmaLexer = false;
+  IsMainFile = false;
   InitCharacterInfo();
       
   assert(BufferEnd[0] == 0 &&

Modified: cfe/cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/Lexer.h?rev=38630&r1=38629&r2=38630&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/Lexer.h Wed Jul 11 11:23:21 2007
@@ -58,6 +58,7 @@
   Preprocessor &PP;              // Preprocessor object controlling lexing.
   LangOptions Features;          // Features enabled by this language (cache).
   bool Is_PragmaLexer;           // True if lexer for _Pragma handling.
+  bool IsMainFile;               // True if top-level file.
   
   // Context-specific lexing flags.
   bool IsAtStartOfLine;          // True if sitting at start of line.
@@ -88,6 +89,16 @@
   /// implicitly encodes the include path to get to the file.
   unsigned getCurFileID() const { return CurFileID; }
   
+  /// setIsMainFile - Mark this lexer as being the lexer for the top-level
+  /// source file.
+  void setIsMainFile() {
+    IsMainFile = true;
+  }
+  
+  /// isMainFile - Return true if this is the top-level file.
+  ///
+  bool isMainFile() const { return IsMainFile; }
+  
   /// Lex - Return the next token in the file.  If this is the end of file, it
   /// return the tok::eof token.  Return true if an error occurred and
   /// compilation should terminate, false if normal.  This implicitly involves





More information about the cfe-commits mailing list