aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/TokenLexer.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-12-01 01:15:54 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-12-01 01:15:54 +0000
commit19c8ce0cf534caa909955ba9a17b7841f574a3be (patch)
tree0e3230e66371925cc4a194176c9508d071266353 /lib/Lex/TokenLexer.cpp
parent056503786410c0e72b1389918719a37e9342817b (diff)
Try to make the source location information for token pastes a bit more consistent.
Fixes a crash printing diagnostics on the gcc testsuite, and also makes diagnostic range printing print nicer results for token pastes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169068 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r--lib/Lex/TokenLexer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index 59b747814a..844d94d06c 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -647,6 +647,12 @@ bool TokenLexer::PasteTokens(Token &Tok) {
StartLoc = getExpansionLocForMacroDefLoc(StartLoc);
if (EndLoc.isFileID())
EndLoc = getExpansionLocForMacroDefLoc(EndLoc);
+ FileID MacroFID = SM.getFileID(MacroExpansionStart);
+ while (SM.getFileID(StartLoc) != MacroFID)
+ StartLoc = SM.getImmediateExpansionRange(StartLoc).first;
+ while (SM.getFileID(EndLoc) != MacroFID)
+ EndLoc = SM.getImmediateExpansionRange(EndLoc).second;
+
Tok.setLocation(SM.createExpansionLoc(Tok.getLocation(), StartLoc, EndLoc,
Tok.getLength()));