diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-18 14:39:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-18 14:39:36 +0000 |
commit | e94ca9e4371c022329270436b3dd77adc4ddfa8f (patch) | |
tree | 88577be07029db31b21b7b0c8e3dbcf593dff4a4 /lib/Parse/ParseExprCXX.cpp | |
parent | db0e15ae3e2b5e180541eec35e2bce54359ca7d8 (diff) |
Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.
Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.
Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.
Extended Declarator to store overloaded operator names.
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator.
Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 006c79158a..90caa859a1 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -149,9 +149,9 @@ Parser::ExprResult Parser::ParseCXXIdExpression() { case tok::kw_operator: { SourceLocation OperatorLoc = Tok.getLocation(); - if (IdentifierInfo *II = TryParseOperatorFunctionId()) { - return Actions.ActOnIdentifierExpr(CurScope, OperatorLoc, *II, - Tok.is(tok::l_paren), &SS); + if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) { + return Actions.ActOnOperatorFunctionIdExpr(CurScope, OperatorLoc, Op, + Tok.is(tok::l_paren), &SS); } else if (TypeTy *Type = ParseConversionFunctionId()) { return Actions.ActOnConversionFunctionExpr(CurScope, OperatorLoc, Type, Tok.is(tok::l_paren), @@ -534,7 +534,7 @@ bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) { /// ^= &= |= << >> >>= <<= == != /// <= >= && || ++ -- , ->* -> /// () [] -IdentifierInfo *Parser::TryParseOperatorFunctionId() { +OverloadedOperatorKind Parser::TryParseOperatorFunctionId() { assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword"); OverloadedOperatorKind Op = OO_None; @@ -549,7 +549,7 @@ IdentifierInfo *Parser::TryParseOperatorFunctionId() { } else { Op = OO_New; } - return &PP.getIdentifierTable().getOverloadedOperator(Op); + return Op; case tok::kw_delete: ConsumeToken(); // 'operator' @@ -561,7 +561,7 @@ IdentifierInfo *Parser::TryParseOperatorFunctionId() { } else { Op = OO_Delete; } - return &PP.getIdentifierTable().getOverloadedOperator(Op); + return Op; #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ case tok::Token: Op = OO_##Name; break; @@ -572,21 +572,21 @@ IdentifierInfo *Parser::TryParseOperatorFunctionId() { ConsumeToken(); // 'operator' ConsumeParen(); // '(' ExpectAndConsume(tok::r_paren, diag::err_expected_rparen); // ')' - return &PP.getIdentifierTable().getOverloadedOperator(OO_Call); + return OO_Call; case tok::l_square: ConsumeToken(); // 'operator' ConsumeBracket(); // '[' ExpectAndConsume(tok::r_square, diag::err_expected_rsquare); // ']' - return &PP.getIdentifierTable().getOverloadedOperator(OO_Subscript); + return OO_Subscript; default: - return 0; + return OO_None; } ConsumeToken(); // 'operator' ConsumeAnyToken(); // the operator itself - return &PP.getIdentifierTable().getOverloadedOperator(Op); + return Op; } /// ParseConversionFunctionId - Parse a C++ conversion-function-id, |