]> granicus.if.org Git - clang/commitdiff
make paste avoidance avoid pasting digraphs and :: only when digraphs or c++ is enabled
authorChris Lattner <sabre@nondot.org>
Sun, 11 Jan 2009 19:48:19 +0000 (19:48 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 11 Jan 2009 19:48:19 +0000 (19:48 +0000)
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

Driver/PrintPreprocessedOutput.cpp

index 923439c07071c084afb0c51488c7b03d3e376bcf..deb005ca4f9f995ffcc71c778443eb4a8ec2993d 100644 (file)
@@ -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:           // ->*