Make SourceLocation::getFileLoc private to reduce the API exposure of
SourceLocation. This requires making some cleanups to token pasting
and _Pragma expansion.
llvm-svn: 62490
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp
index 7e56a43..82c4d92 100644
--- a/clang/lib/Lex/TokenLexer.cpp
+++ b/clang/lib/Lex/TokenLexer.cpp
@@ -388,13 +388,21 @@
} 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*/);