diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-19 23:55:44 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-19 23:55:44 +0000 |
commit | 5e14925a35e87b46d48e6dc6b71a682956c50d55 (patch) | |
tree | 8b5b682f12cb352aad1ac9c9f06f32f6ac5244d3 /clang/lib/Lex/TokenLexer.cpp | |
parent | 6ad6c3b1c24eaca15d56d9a5b4d3ba810a743e33 (diff) | |
download | bcm5719-llvm-5e14925a35e87b46d48e6dc6b71a682956c50d55.tar.gz bcm5719-llvm-5e14925a35e87b46d48e6dc6b71a682956c50d55.zip |
[preprocessor] When "merging" macro argument tokens into one SLocEntry chunk,
make sure they came from the same kind of FileIDs.
Thanks to Abramo Bagnara for providing the test case.
llvm-svn: 170616
Diffstat (limited to 'clang/lib/Lex/TokenLexer.cpp')
-rw-r--r-- | clang/lib/Lex/TokenLexer.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index 8c6f6204eb8..5b41fe9b8d3 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -749,14 +749,18 @@ static void updateConsecutiveMacroArgTokens(SourceManager &SM, Token *NextTok = begin_tokens + 1; for (; NextTok < end_tokens; ++NextTok) { + SourceLocation NextLoc = NextTok->getLocation(); + if (CurLoc.isFileID() != NextLoc.isFileID()) + break; // Token from different kind of FileID. + int RelOffs; - if (!SM.isInSameSLocAddrSpace(CurLoc, NextTok->getLocation(), &RelOffs)) + if (!SM.isInSameSLocAddrSpace(CurLoc, NextLoc, &RelOffs)) break; // Token from different local/loaded location. // Check that token is not before the previous token or more than 50 // "characters" away. if (RelOffs < 0 || RelOffs > 50) break; - CurLoc = NextTok->getLocation(); + CurLoc = NextLoc; } // For the consecutive tokens, find the length of the SLocEntry to contain |