aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Lex/Preprocessor.cpp4
-rw-r--r--lib/Parse/ParseObjc.cpp57
2 files changed, 59 insertions, 2 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 5160acf19e..05621d31b3 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -613,8 +613,10 @@ 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.
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index c36f09c881..8d7d67ed8d 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -553,6 +553,60 @@ 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]
@@ -569,7 +623,6 @@ Decl *Parser::ParseObjCMethodPrototype(Decl *IDecl,
tok::TokenKind methodType = Tok.getKind();
SourceLocation mLoc = ConsumeToken();
-
Decl *MDecl = ParseObjCMethodDecl(mLoc, methodType, IDecl,MethodImplKind);
// Since this rule is used for both method declarations and definitions,
// the caller is (optionally) responsible for consuming the ';'.
@@ -585,6 +638,8 @@ 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;