make the token paste avoidance logic turn "..." into ".. ." instead of ". . ."

when avoiding paste.  Patch by David Peixotto!

llvm-svn: 101218
This commit is contained in:
Chris Lattner
2010-04-14 03:57:19 +00:00
parent dad4062b4d
commit 0384e63501
5 changed files with 20 additions and 8 deletions

View File

@@ -125,8 +125,9 @@ public:
}
bool MoveToLine(unsigned LineNo);
bool AvoidConcat(const Token &PrevTok, const Token &Tok) {
return ConcatInfo.AvoidConcat(PrevTok, Tok);
bool AvoidConcat(const Token &PrevPrevTok, const Token &PrevTok,
const Token &Tok) {
return ConcatInfo.AvoidConcat(PrevPrevTok, PrevTok, Tok);
}
void WriteLineInfo(unsigned LineNo, const char *Extra=0, unsigned ExtraLen=0);
@@ -396,6 +397,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
PrintPPOutputPPCallbacks *Callbacks,
llvm::raw_ostream &OS) {
char Buffer[256];
Token PrevPrevTok;
Token PrevTok;
while (1) {
@@ -407,7 +409,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
// useful to look at and no concatenation could happen anyway.
(Callbacks->hasEmittedTokensOnThisLine() &&
// Don't print "-" next to "-", it would form "--".
Callbacks->AvoidConcat(PrevTok, Tok))) {
Callbacks->AvoidConcat(PrevPrevTok, PrevTok, Tok))) {
OS << ' ';
}
@@ -438,6 +440,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
if (Tok.is(tok::eof)) break;
PrevPrevTok = PrevTok;
PrevTok = Tok;
PP.Lex(Tok);
}