]> granicus.if.org Git - clang/commitdiff
Use getSpelling to get original text of the
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 3 Sep 2010 17:33:04 +0000 (17:33 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 3 Sep 2010 17:33:04 +0000 (17:33 +0000)
c++ operator token. (radar 8328250).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112977 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Token.h
lib/Lex/Preprocessor.cpp
lib/Parse/ParseObjc.cpp

index dc4acd46e29ed0806a5deca07365126711d7cdea..954b36ec6d118a22e237db31aaa9a26eb9bf850f 100644 (file)
@@ -76,9 +76,7 @@ public:
     StartOfLine   = 0x01,  // At start of line or only after whitespace.
     LeadingSpace  = 0x02,  // Whitespace exists before this token.
     DisableExpand = 0x04,  // This identifier may never be macro expanded.
-    NeedsCleaning = 0x08,  // Contained an escaped newline or trigraph.
-    CPlusPlusOpKeyword = 0x10 // alternative representation of
-                              // a C++ operator in objc selectors.
+    NeedsCleaning = 0x08   // Contained an escaped newline or trigraph.
   };
 
   tok::TokenKind getKind() const { return (tok::TokenKind)Kind; }
@@ -233,12 +231,7 @@ public:
   /// newlines in it.
   ///
   bool needsCleaning() const { return (Flags & NeedsCleaning) ? true : false; }
-  
-  /// isCPlusPlusOpKeyword - Return true if this token is an operator 
-  /// for C++ operator keywords.
-  bool isCPlusPlusOpKeyword() const
-  { return (Flags & CPlusPlusOpKeyword) ? true : false; }
-  
+    
 };
 
 /// PPConditionalInfo - Information about the conditional stack (#if directives)
index 05621d31b3f4f8a84254d99890e6f5dd36ba07e7..5160acf19e1f4bad27e7618ba088ee73fdeab85d 100644 (file)
@@ -613,10 +613,8 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
   // C++ 2.11p2: If this is an alternative representation of a C++ operator,
   // then we act as if it is the actual operator and not the textual
   // representation of it.
-  if (II.isCPlusPlusOperatorKeyword()) {
+  if (II.isCPlusPlusOperatorKeyword())
     Identifier.setIdentifierInfo(0);
-    Identifier.setFlag(Token::CPlusPlusOpKeyword);
-  }
 
   // If this is an extension token, diagnose its use.
   // We avoid diagnosing tokens that originate from macro definitions.
index 8d7d67ed8d4f0f96b2815022d272f39f95a3107c..e0f9e2907b5777d34d69215a9920a3c7f96878a5 100644 (file)
@@ -553,60 +553,6 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS, Decl *ClassDecl,
   MatchRHSPunctuation(tok::r_paren, LHSLoc);
 }
 
-static void ConvertCPlusPlusOperatorToken(Preprocessor &PP, Token &Tok) {
-  if (!Tok.isCPlusPlusOpKeyword())
-    return;
-  
-  switch (Tok.getKind()) {
-    case tok::ampamp:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("and"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::ampequal:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("and_eq"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::amp:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("bitand"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::pipe:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("pipe"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::tilde:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("compl"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::exclaim:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("not"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::exclaimequal:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("not_eq"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::pipepipe:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("or"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::pipeequal:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("or_eq"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::caret:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("xor"));
-      Tok.setKind(tok::identifier);
-      return;
-    case tok::caretequal:
-      Tok.setIdentifierInfo(&PP.getIdentifierTable().get("xor_eq"));
-      Tok.setKind(tok::identifier);
-      return;
-    default:
-      return;
-  }
-}
-
 ///   objc-method-proto:
 ///     objc-instance-method objc-method-decl objc-method-attributes[opt]
 ///     objc-class-method objc-method-decl objc-method-attributes[opt]
@@ -638,11 +584,31 @@ Decl *Parser::ParseObjCMethodPrototype(Decl *IDecl,
 ///       in out inout bycopy byref oneway int char float double void _Bool
 ///
 IdentifierInfo *Parser::ParseObjCSelectorPiece(SourceLocation &SelectorLoc) {
-  ConvertCPlusPlusOperatorToken(PP, Tok);
 
   switch (Tok.getKind()) {
   default:
     return 0;
+  case tok::ampamp:
+  case tok::ampequal:
+  case tok::amp:
+  case tok::pipe:
+  case tok::tilde:
+  case tok::exclaim:
+  case tok::exclaimequal:
+  case tok::pipepipe:
+  case tok::pipeequal:
+  case tok::caret:
+  case tok::caretequal: {
+    llvm::StringRef ThisTok = PP.getSpelling(Tok);
+    if (isalpha(ThisTok[0])) {
+      IdentifierInfo *II = &PP.getIdentifierTable().get(ThisTok.data());
+      Tok.setKind(tok::identifier);
+      SelectorLoc = ConsumeToken();
+      return II;
+    }
+    return 0; 
+  }
+      
   case tok::identifier:
   case tok::kw_asm:
   case tok::kw_auto: