diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-17 06:22:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-17 06:22:33 +0000 |
commit | 2b2453a7d8fe732561795431f39ceb2b2a832d84 (patch) | |
tree | ad3d68197002f997b30e6617e41e290eff963b03 /lib/Lex/PPLexerChange.cpp | |
parent | 05816591ec488a933dfecc9ff9f3cbf3c32767c2 (diff) |
this massive patch introduces a simple new abstraction: it makes
"FileID" a concept that is now enforced by the compiler's type checker
instead of yet-another-random-unsigned floating around.
This is an important distinction from the "FileID" currently tracked by
SourceLocation. *That* FileID may refer to the start of a file or to a
chunk within it. The new FileID *only* refers to the file (and its
#include stack and eventually #line data), it cannot refer to a chunk.
FileID is a completely opaque datatype to all clients, only SourceManager
is allowed to poke and prod it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 0ecca3a8cc..cc8ccc4c10 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -66,8 +66,7 @@ PreprocessorLexer *Preprocessor::getCurrentFileLexer() const { /// EnterSourceFile - Add a source file to the top of the include stack and /// start lexing tokens from it instead of the current buffer. Return true /// on failure. -void Preprocessor::EnterSourceFile(unsigned FileID, - const DirectoryLookup *CurDir) { +void Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir) { assert(CurTokenLexer == 0 && "Cannot #include a file inside a macro!"); ++NumEnteredSourceFiles; @@ -75,8 +74,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, MaxIncludeStackDepth = IncludeMacroStack.size(); if (PTH) { - PTHLexer* PL = - PTH->CreateLexer(FileID, getSourceManager().getFileEntryForID(FileID)); + PTHLexer *PL = PTH->CreateLexer(FID, SourceMgr.getFileEntryForID(FID)); if (PL) { EnterSourceFileWithPTH(PL, CurDir); @@ -84,7 +82,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, } } - Lexer *TheLexer = new Lexer(SourceLocation::getFileLoc(FileID, 0), *this); + Lexer *TheLexer = new Lexer(SourceMgr.getLocForStartOfFile(FID), *this); EnterSourceFileWithLexer(TheLexer, CurDir); } @@ -125,10 +123,9 @@ void Preprocessor::EnterSourceFileWithPTH(PTHLexer *PL, // Notify the client, if desired, that we are in a new source file. if (Callbacks) { - unsigned FileID = CurPPLexer->getFileID(); - SrcMgr::CharacteristicKind FileType = - SourceMgr.getFileCharacteristic(CurPPLexer->getFileID()); - Callbacks->FileChanged(SourceLocation::getFileLoc(FileID, 0), + FileID FID = CurPPLexer->getFileID(); + SrcMgr::CharacteristicKind FileType = SourceMgr.getFileCharacteristic(FID); + Callbacks->FileChanged(SourceMgr.getLocForStartOfFile(FID), PPCallbacks::EnterFile, FileType); } } |