diff options
| -rw-r--r-- | clang/Lex/Lexer.cpp | 1 | ||||
| -rw-r--r-- | clang/include/clang/Lex/Lexer.h | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 51d4c73190a..208f25ac60d 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -43,6 +43,7 @@ Lexer::Lexer(const SourceBuffer *File, unsigned fileid, Preprocessor &pp, BufferEnd(BufEnd ? BufEnd : File->getBufferEnd()), InputFile(File), CurFileID(fileid), PP(pp), Features(PP.getLangOptions()) { Is_PragmaLexer = false; + IsMainFile = false; InitCharacterInfo(); assert(BufferEnd[0] == 0 && diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h index 4537cd762e8..377c5751ef0 100644 --- a/clang/include/clang/Lex/Lexer.h +++ b/clang/include/clang/Lex/Lexer.h @@ -58,6 +58,7 @@ class Lexer { 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 @@ public: /// 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 |

