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
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp
index 923439c..deb005c 100644
--- a/Driver/PrintPreprocessedOutput.cpp
+++ b/Driver/PrintPreprocessedOutput.cpp
@@ -438,7 +438,8 @@
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 @@
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: // ->*