summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-03 05:16:05 +0000
committerChris Lattner <sabre@nondot.org>2006-07-03 05:16:05 +0000
commit4ec473f8712d8539cd39076a7e390cf8b2affb78 (patch)
tree6c1f044fbd7a7e0706f682cf131ee56d60a4eaf4
parent040a4ab71e8bf583ceaa2991838c2198eded5bf2 (diff)
downloadbcm5719-llvm-4ec473f8712d8539cd39076a7e390cf8b2affb78.tar.gz
bcm5719-llvm-4ec473f8712d8539cd39076a7e390cf8b2affb78.zip
Add support to track the real top-level file.
llvm-svn: 38630
-rw-r--r--clang/Lex/Lexer.cpp1
-rw-r--r--clang/include/clang/Lex/Lexer.h11
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
OpenPOWER on IntegriCloud