aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-11 19:48:19 +0000
committerChris Lattner <sabre@nondot.org>2009-01-11 19:48:19 +0000
commitd7a7c00e077111a78a3fe644da59624806ef9e65 (patch)
treeee70631f46b0523e06c9a6cfe9d301f54e2edb29
parent2763b3af0a527c3a63cb058b90c22db0b7bcf558 (diff)
make paste avoidance avoid pasting digraphs and :: only when digraphs or c++ is enabled
respectively. Inspired by a patch by Dan Villiom Podlaski Christiansen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62044 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/PrintPreprocessedOutput.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp
index 923439c070..deb005ca4f 100644
--- a/Driver/PrintPreprocessedOutput.cpp
+++ b/Driver/PrintPreprocessedOutput.cpp
@@ -438,7 +438,8 @@ bool PrintPPOutputPPCallbacks::AvoidConcat(const Token &PrevTok,
return isalnum(FirstChar) || Tok.is(tok::numeric_constant) ||
FirstChar == '+' || FirstChar == '-' || FirstChar == '.';
case tok::period: // ..., .*, .1234
- return FirstChar == '.' || FirstChar == '*' || isdigit(FirstChar);
+ return FirstChar == '.' || isdigit(FirstChar) ||
+ (FirstChar == '*' && PP.getLangOptions().CPlusPlus);
case tok::amp: // &&
return FirstChar == '&';
case tok::plus: // ++
@@ -454,9 +455,11 @@ bool PrintPPOutputPPCallbacks::AvoidConcat(const Token &PrevTok,
case tok::pipe: // ||
return FirstChar == '|';
case tok::percent: // %>, %:
- return FirstChar == '>' || FirstChar == ':';
+ return (FirstChar == '>' || FirstChar == ':') &&
+ PP.getLangOptions().Digraphs;
case tok::colon: // ::, :>
- return FirstChar == ':' || FirstChar == '>';
+ return (FirstChar == ':' && PP.getLangOptions().CPlusPlus) ||
+ (FirstChar == '>' && PP.getLangOptions().Digraphs);
case tok::hash: // ##, #@, %:%:
return FirstChar == '#' || FirstChar == '@' || FirstChar == '%';
case tok::arrow: // ->*