forked from OSchip/llvm-project
Eliminate the "old" ways of parsing operator-function-ids and
conversion-function-ids; all clients have moved on to ParseUnqualifiedId. llvm-svn: 86028
This commit is contained in:
parent
220f4277bd
commit
e7b5f81ba5
|
@ -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<DeclPtrTy, 4> TemplateParameterList;
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue