diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-14 03:57:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-14 03:57:19 +0000 |
commit | 8877321ca66b2887c2f377a7f724a62f34fdf1cd (patch) | |
tree | 396c02ca27e0e2d0af0d4316a229527f6eaf9fa3 /lib/Lex/TokenConcatenation.cpp | |
parent | dd17394d225b06376e9ae1d23f36cec463fdef01 (diff) |
make the token paste avoidance logic turn "..." into ".. ." instead of ". . ."
when avoiding paste. Patch by David Peixotto!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenConcatenation.cpp')
-rw-r--r-- | lib/Lex/TokenConcatenation.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Lex/TokenConcatenation.cpp b/lib/Lex/TokenConcatenation.cpp index 51d2e2326f..fc6db2151a 100644 --- a/lib/Lex/TokenConcatenation.cpp +++ b/lib/Lex/TokenConcatenation.cpp @@ -124,7 +124,8 @@ static char GetFirstChar(Preprocessor &PP, const Token &Tok) { /// but the resulting output won't have incorrect concatenations going on. /// Examples include "..", which we print with a space between, because we /// don't want to track enough to tell "x.." from "...". -bool TokenConcatenation::AvoidConcat(const Token &PrevTok, +bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok, + const Token &PrevTok, const Token &Tok) const { // First, check to see if the tokens were directly adjacent in the original // source. If they were, it must be okay to stick them together: if there @@ -192,7 +193,8 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok, return isalnum(FirstChar) || Tok.is(tok::numeric_constant) || FirstChar == '+' || FirstChar == '-' || FirstChar == '.'; case tok::period: // ..., .*, .1234 - return FirstChar == '.' || isdigit(FirstChar) || + return (FirstChar == '.' && PrevPrevTok.is(tok::period)) || + isdigit(FirstChar) || (PP.getLangOptions().CPlusPlus && FirstChar == '*'); case tok::amp: // && return FirstChar == '&'; |