From 1cf7f0adb4a9cbb9cc971a46af5eca9fcb6c566e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 4 Nov 2009 16:32:12 +0000 Subject: [PATCH] Eliminate the "old" ways of parsing operator-function-ids and conversion-function-ids; all clients have moved on to ParseUnqualifiedId. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86028 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Parse/Parser.h | 7 -- lib/Parse/ParseExprCXX.cpp | 135 ----------------------------------- 2 files changed, 142 deletions(-) diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index f34d469d98..1ca92edc9a 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -1320,13 +1320,6 @@ private: TypeTy *ObjectType, UnqualifiedId &Result); - //===--------------------------------------------------------------------===// - // C++ 13.5: Overloaded operators [over.oper] - // EndLoc, if non-NULL, is filled with the location of the last token of - // the ID. - OverloadedOperatorKind TryParseOperatorFunctionId(SourceLocation *EndLoc = 0); - TypeTy *ParseConversionFunctionId(SourceLocation *EndLoc = 0); - //===--------------------------------------------------------------------===// // C++ 14: Templates [temp] typedef llvm::SmallVector TemplateParameterList; diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index a7ca0c54db..a00dfb0b4c 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -1196,141 +1196,6 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, return true; } -/// TryParseOperatorFunctionId - Attempts to parse a C++ overloaded -/// operator name (C++ [over.oper]). If successful, returns the -/// predefined identifier that corresponds to that overloaded -/// operator. Otherwise, returns NULL and does not consume any tokens. -/// -/// operator-function-id: [C++ 13.5] -/// 'operator' operator -/// -/// operator: one of -/// new delete new[] delete[] -/// + - * / % ^ & | ~ -/// ! = < > += -= *= /= %= -/// ^= &= |= << >> >>= <<= == != -/// <= >= && || ++ -- , ->* -> -/// () [] -OverloadedOperatorKind -Parser::TryParseOperatorFunctionId(SourceLocation *EndLoc) { - assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword"); - SourceLocation Loc; - - OverloadedOperatorKind Op = OO_None; - switch (NextToken().getKind()) { - case tok::kw_new: - ConsumeToken(); // 'operator' - Loc = ConsumeToken(); // 'new' - if (Tok.is(tok::l_square)) { - ConsumeBracket(); // '[' - Loc = Tok.getLocation(); - ExpectAndConsume(tok::r_square, diag::err_expected_rsquare); // ']' - Op = OO_Array_New; - } else { - Op = OO_New; - } - if (EndLoc) - *EndLoc = Loc; - return Op; - - case tok::kw_delete: - ConsumeToken(); // 'operator' - Loc = ConsumeToken(); // 'delete' - if (Tok.is(tok::l_square)) { - ConsumeBracket(); // '[' - Loc = Tok.getLocation(); - ExpectAndConsume(tok::r_square, diag::err_expected_rsquare); // ']' - Op = OO_Array_Delete; - } else { - Op = OO_Delete; - } - if (EndLoc) - *EndLoc = Loc; - return Op; - -#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ - case tok::Token: Op = OO_##Name; break; -#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) -#include "clang/Basic/OperatorKinds.def" - - case tok::l_paren: - ConsumeToken(); // 'operator' - ConsumeParen(); // '(' - Loc = Tok.getLocation(); - ExpectAndConsume(tok::r_paren, diag::err_expected_rparen); // ')' - if (EndLoc) - *EndLoc = Loc; - return OO_Call; - - case tok::l_square: - ConsumeToken(); // 'operator' - ConsumeBracket(); // '[' - Loc = Tok.getLocation(); - ExpectAndConsume(tok::r_square, diag::err_expected_rsquare); // ']' - if (EndLoc) - *EndLoc = Loc; - return OO_Subscript; - - case tok::code_completion: { - // Code completion for the operator name. - Actions.CodeCompleteOperatorName(CurScope); - - // Consume the 'operator' token, then replace the code-completion token - // with an 'operator' token and try again. - SourceLocation OperatorLoc = ConsumeToken(); - Tok.setLocation(OperatorLoc); - Tok.setKind(tok::kw_operator); - return TryParseOperatorFunctionId(EndLoc); - } - - default: - return OO_None; - } - - ConsumeToken(); // 'operator' - Loc = ConsumeAnyToken(); // the operator itself - if (EndLoc) - *EndLoc = Loc; - return Op; -} - -/// ParseConversionFunctionId - Parse a C++ conversion-function-id, -/// which expresses the name of a user-defined conversion operator -/// (C++ [class.conv.fct]p1). Returns the type that this operator is -/// specifying a conversion for, or NULL if there was an error. -/// -/// conversion-function-id: [C++ 12.3.2] -/// operator conversion-type-id -/// -/// conversion-type-id: -/// type-specifier-seq conversion-declarator[opt] -/// -/// conversion-declarator: -/// ptr-operator conversion-declarator[opt] -Parser::TypeTy *Parser::ParseConversionFunctionId(SourceLocation *EndLoc) { - assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword"); - ConsumeToken(); // 'operator' - - // Parse the type-specifier-seq. - DeclSpec DS; - if (ParseCXXTypeSpecifierSeq(DS)) - return 0; - - // Parse the conversion-declarator, which is merely a sequence of - // ptr-operators. - Declarator D(DS, Declarator::TypeNameContext); - ParseDeclaratorInternal(D, /*DirectDeclParser=*/0); - if (EndLoc) - *EndLoc = D.getSourceRange().getEnd(); - - // Finish up the type. - Action::TypeResult Result = Actions.ActOnTypeName(CurScope, D); - if (Result.isInvalid()) - return 0; - else - return Result.get(); -} - /// ParseCXXNewExpression - Parse a C++ new-expression. New is used to allocate /// memory in a typesafe manner and call constructors. /// -- 2.40.0