diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-19 06:46:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-19 06:46:35 +0000 |
commit | bcc2a67e5180612417727cbdd8afd0f79fdf726d (patch) | |
tree | 6ec0a17c76a1d8ac80373d73b1e732d125dffc79 /lib/Lex/TokenLexer.cpp | |
parent | ec0d7a6f4b0699cc9960e6d9fee0f957c64d1cf9 (diff) |
Make SourceLocation::getFileLoc private to reduce the API exposure of
SourceLocation. This requires making some cleanups to token pasting
and _Pragma expansion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62490 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 7e56a43c44..82c4d926ae 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -388,13 +388,21 @@ bool TokenLexer::PasteTokens(Token &Tok) { } else { PP.IncrementPasteCounter(false); - // Make a lexer to lex this string from. + assert(ResultTokLoc.isFileID() && + "Should be a raw location into scratch buffer"); SourceManager &SourceMgr = PP.getSourceManager(); - const char *ResultStrData = SourceMgr.getCharacterData(ResultTokLoc); + std::pair<FileID, unsigned> LocInfo = + SourceMgr.getDecomposedFileLoc(ResultTokLoc); + + const char *ScratchBufStart =SourceMgr.getBufferData(LocInfo.first).first; + + // Make a lexer to lex this string from. Lex just this one token. + const char *ResultStrData = ScratchBufStart+LocInfo.second; // Make a lexer object so that we lex and expand the paste result. - Lexer TL(ResultTokLoc, PP.getLangOptions(), - SourceMgr.getBufferData(ResultTokLoc).first, + Lexer TL(SourceMgr.getLocForStartOfFile(LocInfo.first), + PP.getLangOptions(), + ScratchBufStart, ResultStrData, ResultStrData+LHSLen+RHSLen /*don't include null*/); |