aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseTentative.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Parse/ParseTentative.cpp')
-rw-r--r--lib/Parse/ParseTentative.cpp400
1 files changed, 182 insertions, 218 deletions
diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp
index a1d6b13fdab8..8514af2a8c89 100644
--- a/lib/Parse/ParseTentative.cpp
+++ b/lib/Parse/ParseTentative.cpp
@@ -101,15 +101,15 @@ bool Parser::isCXXSimpleDeclaration(bool AllowForRangeDecl) {
// an ambiguity if the first decl-specifier is
// simple-type-specifier/typename-specifier followed by a '(', which may
// indicate a function-style cast expression.
- // isCXXDeclarationSpecifier will return TPResult::Ambiguous() only in such
+ // isCXXDeclarationSpecifier will return TPResult::Ambiguous only in such
// a case.
bool InvalidAsDeclaration = false;
- TPResult TPR = isCXXDeclarationSpecifier(TPResult::False(),
+ TPResult TPR = isCXXDeclarationSpecifier(TPResult::False,
&InvalidAsDeclaration);
- if (TPR != TPResult::Ambiguous())
- return TPR != TPResult::False(); // Returns true for TPResult::True() or
- // TPResult::Error().
+ if (TPR != TPResult::Ambiguous)
+ return TPR != TPResult::False; // Returns true for TPResult::True or
+ // TPResult::Error.
// FIXME: TryParseSimpleDeclaration doesn't look past the first initializer,
// and so gets some cases wrong. We can't carry on if we've already seen
@@ -131,15 +131,15 @@ bool Parser::isCXXSimpleDeclaration(bool AllowForRangeDecl) {
PA.Revert();
// In case of an error, let the declaration parsing code handle it.
- if (TPR == TPResult::Error())
+ if (TPR == TPResult::Error)
return true;
// Declarations take precedence over expressions.
- if (TPR == TPResult::Ambiguous())
- TPR = TPResult::True();
+ if (TPR == TPResult::Ambiguous)
+ TPR = TPResult::True;
- assert(TPR == TPResult::True() || TPR == TPResult::False());
- return TPR == TPResult::True();
+ assert(TPR == TPResult::True || TPR == TPResult::False);
+ return TPR == TPResult::True;
}
/// Try to consume a token sequence that we've already identified as
@@ -157,10 +157,10 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() {
case tok::kw___underlying_type: {
ConsumeToken();
if (Tok.isNot(tok::l_paren))
- return TPResult::Error();
+ return TPResult::Error;
ConsumeParen();
if (!SkipUntil(tok::r_paren))
- return TPResult::Error();
+ return TPResult::Error;
break;
}
@@ -184,23 +184,23 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() {
if (Tok.is(tok::l_square)) {
ConsumeBracket();
if (!SkipUntil(tok::r_square))
- return TPResult::Error();
+ return TPResult::Error;
} else {
ConsumeToken();
if (Tok.isNot(tok::l_paren))
- return TPResult::Error();
+ return TPResult::Error;
ConsumeParen();
if (!SkipUntil(tok::r_paren))
- return TPResult::Error();
+ return TPResult::Error;
}
}
if (TryAnnotateCXXScopeToken())
- return TPResult::Error();
+ return TPResult::Error;
if (Tok.is(tok::annot_cxxscope))
ConsumeToken();
if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id))
- return TPResult::Error();
+ return TPResult::Error;
ConsumeToken();
break;
@@ -215,7 +215,7 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() {
break;
}
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
/// simple-declaration:
@@ -227,29 +227,29 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() {
/// attribute-specifier-seqopt type-specifier-seq declarator
///
Parser::TPResult Parser::TryParseSimpleDeclaration(bool AllowForRangeDecl) {
- if (TryConsumeDeclarationSpecifier() == TPResult::Error())
- return TPResult::Error();
+ if (TryConsumeDeclarationSpecifier() == TPResult::Error)
+ return TPResult::Error;
// Two decl-specifiers in a row conclusively disambiguate this as being a
// simple-declaration. Don't bother calling isCXXDeclarationSpecifier in the
// overwhelmingly common case that the next token is a '('.
if (Tok.isNot(tok::l_paren)) {
TPResult TPR = isCXXDeclarationSpecifier();
- if (TPR == TPResult::Ambiguous())
- return TPResult::True();
- if (TPR == TPResult::True() || TPR == TPResult::Error())
+ if (TPR == TPResult::Ambiguous)
+ return TPResult::True;
+ if (TPR == TPResult::True || TPR == TPResult::Error)
return TPR;
- assert(TPR == TPResult::False());
+ assert(TPR == TPResult::False);
}
TPResult TPR = TryParseInitDeclaratorList();
- if (TPR != TPResult::Ambiguous())
+ if (TPR != TPResult::Ambiguous)
return TPR;
if (Tok.isNot(tok::semi) && (!AllowForRangeDecl || Tok.isNot(tok::colon)))
- return TPResult::False();
+ return TPResult::False;
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
/// Tentatively parse an init-declarator-list in order to disambiguate it from
@@ -283,23 +283,23 @@ Parser::TPResult Parser::TryParseInitDeclaratorList() {
while (1) {
// declarator
TPResult TPR = TryParseDeclarator(false/*mayBeAbstract*/);
- if (TPR != TPResult::Ambiguous())
+ if (TPR != TPResult::Ambiguous)
return TPR;
// [GNU] simple-asm-expr[opt] attributes[opt]
if (Tok.is(tok::kw_asm) || Tok.is(tok::kw___attribute))
- return TPResult::True();
+ return TPResult::True;
// initializer[opt]
if (Tok.is(tok::l_paren)) {
// Parse through the parens.
ConsumeParen();
if (!SkipUntil(tok::r_paren, StopAtSemi))
- return TPResult::Error();
+ return TPResult::Error;
} else if (Tok.is(tok::l_brace)) {
// A left-brace here is sufficient to disambiguate the parse; an
// expression can never be followed directly by a braced-init-list.
- return TPResult::True();
+ return TPResult::True;
} else if (Tok.is(tok::equal) || isTokIdentifier_in()) {
// MSVC and g++ won't examine the rest of declarators if '=' is
// encountered; they just conclude that we have a declaration.
@@ -317,15 +317,14 @@ Parser::TPResult Parser::TryParseInitDeclaratorList() {
// in any other context 'in' is invalid after a declaration and parser
// issues the error regardless of outcome of this decision.
// FIXME: Change if above assumption does not hold.
- return TPResult::True();
+ return TPResult::True;
}
- if (Tok.isNot(tok::comma))
+ if (!TryConsumeToken(tok::comma))
break;
- ConsumeToken(); // the comma.
}
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
/// isCXXConditionDeclaration - Disambiguates between a declaration or an
@@ -343,9 +342,9 @@ Parser::TPResult Parser::TryParseInitDeclaratorList() {
///
bool Parser::isCXXConditionDeclaration() {
TPResult TPR = isCXXDeclarationSpecifier();
- if (TPR != TPResult::Ambiguous())
- return TPR != TPResult::False(); // Returns true for TPResult::True() or
- // TPResult::Error().
+ if (TPR != TPResult::Ambiguous)
+ return TPR != TPResult::False; // Returns true for TPResult::True or
+ // TPResult::Error.
// FIXME: Add statistics about the number of ambiguous statements encountered
// and how they were resolved (number of declarations+number of expressions).
@@ -363,25 +362,25 @@ bool Parser::isCXXConditionDeclaration() {
TPR = TryParseDeclarator(false/*mayBeAbstract*/);
// In case of an error, let the declaration parsing code handle it.
- if (TPR == TPResult::Error())
- TPR = TPResult::True();
+ if (TPR == TPResult::Error)
+ TPR = TPResult::True;
- if (TPR == TPResult::Ambiguous()) {
+ if (TPR == TPResult::Ambiguous) {
// '='
// [GNU] simple-asm-expr[opt] attributes[opt]
if (Tok.is(tok::equal) ||
Tok.is(tok::kw_asm) || Tok.is(tok::kw___attribute))
- TPR = TPResult::True();
+ TPR = TPResult::True;
else if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace))
- TPR = TPResult::True();
+ TPR = TPResult::True;
else
- TPR = TPResult::False();
+ TPR = TPResult::False;
}
PA.Revert();
- assert(TPR == TPResult::True() || TPR == TPResult::False());
- return TPR == TPResult::True();
+ assert(TPR == TPResult::True || TPR == TPResult::False);
+ return TPR == TPResult::True;
}
/// \brief Determine whether the next set of tokens contains a type-id.
@@ -413,9 +412,9 @@ bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous) {
// in its syntactic context shall be considered a type-id.
TPResult TPR = isCXXDeclarationSpecifier();
- if (TPR != TPResult::Ambiguous())
- return TPR != TPResult::False(); // Returns true for TPResult::True() or
- // TPResult::Error().
+ if (TPR != TPResult::Ambiguous)
+ return TPR != TPResult::False; // Returns true for TPResult::True or
+ // TPResult::Error.
// FIXME: Add statistics about the number of ambiguous statements encountered
// and how they were resolved (number of declarations+number of expressions).
@@ -433,14 +432,14 @@ bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous) {
TPR = TryParseDeclarator(true/*mayBeAbstract*/, false/*mayHaveIdentifier*/);
// In case of an error, let the declaration parsing code handle it.
- if (TPR == TPResult::Error())
- TPR = TPResult::True();
+ if (TPR == TPResult::Error)
+ TPR = TPResult::True;
- if (TPR == TPResult::Ambiguous()) {
+ if (TPR == TPResult::Ambiguous) {
// We are supposed to be inside parens, so if after the abstract declarator
// we encounter a ')' this is a type-id, otherwise it's an expression.
if (Context == TypeIdInParens && Tok.is(tok::r_paren)) {
- TPR = TPResult::True();
+ TPR = TPResult::True;
isAmbiguous = true;
// We are supposed to be inside a template argument, so if after
@@ -449,17 +448,17 @@ bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous) {
} else if (Context == TypeIdAsTemplateArgument &&
(Tok.is(tok::greater) || Tok.is(tok::comma) ||
(getLangOpts().CPlusPlus11 && Tok.is(tok::greatergreater)))) {
- TPR = TPResult::True();
+ TPR = TPResult::True;
isAmbiguous = true;
} else
- TPR = TPResult::False();
+ TPR = TPResult::False;
}
PA.Revert();
- assert(TPR == TPResult::True() || TPR == TPResult::False());
- return TPR == TPResult::True();
+ assert(TPR == TPResult::True || TPR == TPResult::False);
+ return TPR == TPResult::True;
}
/// \brief Returns true if this is a C++11 attribute-specifier. Per
@@ -595,13 +594,10 @@ Parser::isCXX11AttributeSpecifier(bool Disambiguate,
}
}
- if (Tok.is(tok::ellipsis))
- ConsumeToken();
+ TryConsumeToken(tok::ellipsis);
- if (Tok.isNot(tok::comma))
+ if (!TryConsumeToken(tok::comma))
break;
-
- ConsumeToken();
}
// An attribute must end ']]'.
@@ -628,7 +624,7 @@ Parser::TPResult Parser::TryParsePtrOperatorSeq() {
while (true) {
if (Tok.is(tok::coloncolon) || Tok.is(tok::identifier))
if (TryAnnotateCXXScopeToken(true))
- return TPResult::Error();
+ return TPResult::Error;
if (Tok.is(tok::star) || Tok.is(tok::amp) || Tok.is(tok::caret) ||
Tok.is(tok::ampamp) ||
@@ -640,7 +636,7 @@ Parser::TPResult Parser::TryParsePtrOperatorSeq() {
Tok.is(tok::kw_restrict))
ConsumeToken();
} else {
- return TPResult::True();
+ return TPResult::True;
}
}
}
@@ -675,20 +671,20 @@ Parser::TPResult Parser::TryParseOperatorId() {
ConsumeBracket();
ConsumeBracket();
}
- return TPResult::True();
+ return TPResult::True;
#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemOnly) \
case tok::Token:
#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemOnly)
#include "clang/Basic/OperatorKinds.def"
ConsumeToken();
- return TPResult::True();
+ return TPResult::True;
case tok::l_square:
if (NextToken().is(tok::r_square)) {
ConsumeBracket();
ConsumeBracket();
- return TPResult::True();
+ return TPResult::True;
}
break;
@@ -696,7 +692,7 @@ Parser::TPResult Parser::TryParseOperatorId() {
if (NextToken().is(tok::r_paren)) {
ConsumeParen();
ConsumeParen();
- return TPResult::True();
+ return TPResult::True;
}
break;
@@ -716,24 +712,24 @@ Parser::TPResult Parser::TryParseOperatorId() {
if (Tok.is(tok::identifier))
ConsumeToken();
else
- return TPResult::Error();
+ return TPResult::Error;
}
- return TPResult::True();
+ return TPResult::True;
}
// Maybe this is a conversion-function-id.
bool AnyDeclSpecifiers = false;
while (true) {
TPResult TPR = isCXXDeclarationSpecifier();
- if (TPR == TPResult::Error())
+ if (TPR == TPResult::Error)
return TPR;
- if (TPR == TPResult::False()) {
+ if (TPR == TPResult::False) {
if (!AnyDeclSpecifiers)
- return TPResult::Error();
+ return TPResult::Error;
break;
}
- if (TryConsumeDeclarationSpecifier() == TPResult::Error())
- return TPResult::Error();
+ if (TryConsumeDeclarationSpecifier() == TPResult::Error)
+ return TPResult::Error;
AnyDeclSpecifiers = true;
}
return TryParsePtrOperatorSeq();
@@ -797,8 +793,8 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
// declarator:
// direct-declarator
// ptr-operator declarator
- if (TryParsePtrOperatorSeq() == TPResult::Error())
- return TPResult::Error();
+ if (TryParsePtrOperatorSeq() == TPResult::Error)
+ return TPResult::Error;
// direct-declarator:
// direct-abstract-declarator:
@@ -815,8 +811,8 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
else if (Tok.is(tok::identifier))
TentativelyDeclaredIdentifiers.push_back(Tok.getIdentifierInfo());
if (Tok.is(tok::kw_operator)) {
- if (TryParseOperatorId() == TPResult::Error())
- return TPResult::Error();
+ if (TryParseOperatorId() == TPResult::Error)
+ return TPResult::Error;
} else
ConsumeToken();
} else if (Tok.is(tok::l_paren)) {
@@ -829,7 +825,7 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
// '(' parameter-declaration-clause ')' cv-qualifier-seq[opt]
// exception-specification[opt]
TPResult TPR = TryParseFunctionDeclarator();
- if (TPR != TPResult::Ambiguous())
+ if (TPR != TPResult::Ambiguous)
return TPR;
} else {
// '(' declarator ')'
@@ -842,20 +838,20 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
Tok.is(tok::kw___fastcall) ||
Tok.is(tok::kw___thiscall) ||
Tok.is(tok::kw___unaligned))
- return TPResult::True(); // attributes indicate declaration
+ return TPResult::True; // attributes indicate declaration
TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
- if (TPR != TPResult::Ambiguous())
+ if (TPR != TPResult::Ambiguous)
return TPR;
if (Tok.isNot(tok::r_paren))
- return TPResult::False();
+ return TPResult::False;
ConsumeParen();
}
} else if (!mayBeAbstract) {
- return TPResult::False();
+ return TPResult::False;
}
while (1) {
- TPResult TPR(TPResult::Ambiguous());
+ TPResult TPR(TPResult::Ambiguous);
// abstract-declarator: ...
if (Tok.is(tok::ellipsis))
@@ -881,11 +877,11 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
break;
}
- if (TPR != TPResult::Ambiguous())
+ if (TPR != TPResult::Ambiguous)
return TPR;
}
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
Parser::TPResult
@@ -935,42 +931,19 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) {
case tok::kw___alignof:
case tok::kw___builtin_choose_expr:
case tok::kw___builtin_offsetof:
- case tok::kw___builtin_types_compatible_p:
case tok::kw___builtin_va_arg:
case tok::kw___imag:
case tok::kw___real:
case tok::kw___FUNCTION__:
case tok::kw___FUNCDNAME__:
+ case tok::kw___FUNCSIG__:
case tok::kw_L__FUNCTION__:
case tok::kw___PRETTY_FUNCTION__:
- case tok::kw___has_nothrow_assign:
- case tok::kw___has_nothrow_copy:
- case tok::kw___has_nothrow_constructor:
- case tok::kw___has_trivial_assign:
- case tok::kw___has_trivial_copy:
- case tok::kw___has_trivial_constructor:
- case tok::kw___has_trivial_destructor:
- case tok::kw___has_virtual_destructor:
- case tok::kw___is_abstract:
- case tok::kw___is_base_of:
- case tok::kw___is_class:
- case tok::kw___is_convertible_to:
- case tok::kw___is_empty:
- case tok::kw___is_enum:
- case tok::kw___is_interface_class:
- case tok::kw___is_final:
- case tok::kw___is_literal:
- case tok::kw___is_literal_type:
- case tok::kw___is_pod:
- case tok::kw___is_polymorphic:
- case tok::kw___is_sealed:
- case tok::kw___is_trivial:
- case tok::kw___is_trivially_assignable:
- case tok::kw___is_trivially_constructible:
- case tok::kw___is_trivially_copyable:
- case tok::kw___is_union:
case tok::kw___uuidof:
- return TPResult::True();
+#define TYPE_TRAIT(N,Spelling,K) \
+ case tok::kw_##Spelling:
+#include "clang/Basic/TokenKinds.def"
+ return TPResult::True;
// Obviously starts a type-specifier-seq:
case tok::kw_char:
@@ -1015,22 +988,14 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) {
case tok::kw___vector:
case tok::kw___pixel:
case tok::kw__Atomic:
- case tok::kw_image1d_t:
- case tok::kw_image1d_array_t:
- case tok::kw_image1d_buffer_t:
- case tok::kw_image2d_t:
- case tok::kw_image2d_array_t:
- case tok::kw_image3d_t:
- case tok::kw_sampler_t:
- case tok::kw_event_t:
case tok::kw___unknown_anytype:
- return TPResult::False();
+ return TPResult::False;
default:
break;
}
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
bool Parser::isTentativelyDeclared(IdentifierInfo *II) {
@@ -1039,16 +1004,16 @@ bool Parser::isTentativelyDeclared(IdentifierInfo *II) {
!= TentativelyDeclaredIdentifiers.end();
}
-/// isCXXDeclarationSpecifier - Returns TPResult::True() if it is a declaration
-/// specifier, TPResult::False() if it is not, TPResult::Ambiguous() if it could
-/// be either a decl-specifier or a function-style cast, and TPResult::Error()
+/// isCXXDeclarationSpecifier - Returns TPResult::True if it is a declaration
+/// specifier, TPResult::False if it is not, TPResult::Ambiguous if it could
+/// be either a decl-specifier or a function-style cast, and TPResult::Error
/// if a parsing error was found and reported.
///
/// If HasMissingTypename is provided, a name with a dependent scope specifier
/// will be treated as ambiguous if the 'typename' keyword is missing. If this
/// happens, *HasMissingTypename will be set to 'true'. This will also be used
/// as an indicator that undeclared identifiers (which will trigger a later
-/// parse error) should be treated as types. Returns TPResult::Ambiguous() in
+/// parse error) should be treated as types. Returns TPResult::Ambiguous in
/// such cases.
///
/// decl-specifier:
@@ -1152,12 +1117,12 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
// Check for need to substitute AltiVec __vector keyword
// for "vector" identifier.
if (TryAltiVecVectorToken())
- return TPResult::True();
+ return TPResult::True;
const Token &Next = NextToken();
// In 'foo bar', 'foo' is always a type name outside of Objective-C.
if (!getLangOpts().ObjC1 && Next.is(tok::identifier))
- return TPResult::True();
+ return TPResult::True;
if (Next.isNot(tok::coloncolon) && Next.isNot(tok::less)) {
// Determine whether this is a valid expression. If not, we will hit
@@ -1170,15 +1135,15 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
switch (TryAnnotateName(false /* no nested name specifier */,
&TypoCorrection)) {
case ANK_Error:
- return TPResult::Error();
+ return TPResult::Error;
case ANK_TentativeDecl:
- return TPResult::False();
+ return TPResult::False;
case ANK_TemplateName:
// A bare type template-name which can't be a template template
// argument is an error, and was probably intended to be a type.
- return GreaterThanIsOperator ? TPResult::True() : TPResult::False();
+ return GreaterThanIsOperator ? TPResult::True : TPResult::False;
case ANK_Unresolved:
- return HasMissingTypename ? TPResult::Ambiguous() : TPResult::False();
+ return HasMissingTypename ? TPResult::Ambiguous : TPResult::False;
case ANK_Success:
break;
}
@@ -1190,12 +1155,12 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
// since it will annotate as a primary expression, and we want to use the
// "missing 'typename'" logic.
if (TryAnnotateTypeOrScopeToken())
- return TPResult::Error();
+ return TPResult::Error;
// If annotation failed, assume it's a non-type.
// FIXME: If this happens due to an undeclared identifier, treat it as
// ambiguous.
if (Tok.is(tok::identifier))
- return TPResult::False();
+ return TPResult::False;
}
// We annotated this token as something. Recurse to handle whatever we got.
@@ -1206,21 +1171,21 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
- return TPResult::Error();
+ return TPResult::Error;
return isCXXDeclarationSpecifier(BracedCastResult, HasMissingTypename);
case tok::coloncolon: { // ::foo::bar
const Token &Next = NextToken();
if (Next.is(tok::kw_new) || // ::new
Next.is(tok::kw_delete)) // ::delete
- return TPResult::False();
+ return TPResult::False;
}
// Fall through.
case tok::kw_decltype:
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
- return TPResult::Error();
+ return TPResult::Error;
return isCXXDeclarationSpecifier(BracedCastResult, HasMissingTypename);
// decl-specifier:
@@ -1277,7 +1242,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
case tok::kw_restrict:
case tok::kw__Complex:
case tok::kw___attribute:
- return TPResult::True();
+ return TPResult::True;
// Microsoft
case tok::kw___declspec:
@@ -1292,20 +1257,20 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
case tok::kw___ptr32:
case tok::kw___forceinline:
case tok::kw___unaligned:
- return TPResult::True();
+ return TPResult::True;
// Borland
case tok::kw___pascal:
- return TPResult::True();
+ return TPResult::True;
// AltiVec
case tok::kw___vector:
- return TPResult::True();
+ return TPResult::True;
case tok::annot_template_id: {
TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
if (TemplateId->Kind != TNK_Type_template)
- return TPResult::False();
+ return TPResult::False;
CXXScopeSpec SS;
AnnotateTemplateIdTokenAsType();
assert(Tok.is(tok::annot_typename));
@@ -1315,7 +1280,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
case tok::annot_cxxscope: // foo::bar or ::foo::bar, but already parsed
// We've already annotated a scope; try to annotate a type.
if (TryAnnotateTypeOrScopeToken())
- return TPResult::Error();
+ return TPResult::Error;
if (!Tok.is(tok::annot_typename)) {
// If the next token is an identifier or a type qualifier, then this
// can't possibly be a valid expression either.
@@ -1329,37 +1294,37 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
ConsumeToken();
ConsumeToken();
bool isIdentifier = Tok.is(tok::identifier);
- TPResult TPR = TPResult::False();
+ TPResult TPR = TPResult::False;
if (!isIdentifier)
TPR = isCXXDeclarationSpecifier(BracedCastResult,
HasMissingTypename);
PA.Revert();
if (isIdentifier ||
- TPR == TPResult::True() || TPR == TPResult::Error())
- return TPResult::Error();
+ TPR == TPResult::True || TPR == TPResult::Error)
+ return TPResult::Error;
if (HasMissingTypename) {
// We can't tell whether this is a missing 'typename' or a valid
// expression.
*HasMissingTypename = true;
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
} else {
// Try to resolve the name. If it doesn't exist, assume it was
// intended to name a type and keep disambiguating.
switch (TryAnnotateName(false /* SS is not dependent */)) {
case ANK_Error:
- return TPResult::Error();
+ return TPResult::Error;
case ANK_TentativeDecl:
- return TPResult::False();
+ return TPResult::False;
case ANK_TemplateName:
// A bare type template-name which can't be a template template
// argument is an error, and was probably intended to be a type.
- return GreaterThanIsOperator ? TPResult::True() : TPResult::False();
+ return GreaterThanIsOperator ? TPResult::True : TPResult::False;
case ANK_Unresolved:
- return HasMissingTypename ? TPResult::Ambiguous()
- : TPResult::False();
+ return HasMissingTypename ? TPResult::Ambiguous
+ : TPResult::False;
case ANK_Success:
// Annotated it, check again.
assert(Tok.isNot(tok::annot_cxxscope) ||
@@ -1369,7 +1334,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
}
}
}
- return TPResult::False();
+ return TPResult::False;
}
// If that succeeded, fallthrough into the generic simple-type-id case.
@@ -1405,16 +1370,16 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
PA.Revert();
- if (TPR == TPResult::Error())
- return TPResult::Error();
+ if (TPR == TPResult::Error)
+ return TPResult::Error;
if (isFollowedByParen)
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
if (getLangOpts().CPlusPlus11 && isFollowedByBrace)
return BracedCastResult;
- return TPResult::True();
+ return TPResult::True;
}
case tok::kw_char:
@@ -1435,7 +1400,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
case tok::kw_void:
case tok::annot_decltype:
if (NextToken().is(tok::l_paren))
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
// This is a function-style cast in all cases we disambiguate other than
// one:
@@ -1447,14 +1412,14 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
return BracedCastResult;
if (isStartOfObjCClassMessageMissingOpenBracket())
- return TPResult::False();
+ return TPResult::False;
- return TPResult::True();
+ return TPResult::True;
// GNU typeof support.
case tok::kw_typeof: {
if (NextToken().isNot(tok::l_paren))
- return TPResult::True();
+ return TPResult::True;
TentativeParsingAction PA(*this);
@@ -1464,28 +1429,28 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
PA.Revert();
- if (TPR == TPResult::Error())
- return TPResult::Error();
+ if (TPR == TPResult::Error)
+ return TPResult::Error;
if (isFollowedByParen)
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
if (getLangOpts().CPlusPlus11 && isFollowedByBrace)
return BracedCastResult;
- return TPResult::True();
+ return TPResult::True;
}
// C++0x type traits support
case tok::kw___underlying_type:
- return TPResult::True();
+ return TPResult::True;
// C11 _Atomic
case tok::kw__Atomic:
- return TPResult::True();
+ return TPResult::True;
default:
- return TPResult::False();
+ return TPResult::False;
}
}
@@ -1551,9 +1516,9 @@ Parser::TPResult Parser::TryParseTypeofSpecifier() {
// Parse through the parens after 'typeof'.
ConsumeParen();
if (!SkipUntil(tok::r_paren, StopAtSemi))
- return TPResult::Error();
+ return TPResult::Error;
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
/// [ObjC] protocol-qualifiers:
@@ -1563,7 +1528,7 @@ Parser::TPResult Parser::TryParseProtocolQualifiers() {
ConsumeToken();
do {
if (Tok.isNot(tok::identifier))
- return TPResult::Error();
+ return TPResult::Error;
ConsumeToken();
if (Tok.is(tok::comma)) {
@@ -1573,11 +1538,11 @@ Parser::TPResult Parser::TryParseProtocolQualifiers() {
if (Tok.is(tok::greater)) {
ConsumeToken();
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
} while (false);
- return TPResult::Error();
+ return TPResult::Error;
}
/// isCXXFunctionDeclarator - Disambiguates between a function declarator or
@@ -1606,9 +1571,9 @@ bool Parser::isCXXFunctionDeclarator(bool *IsAmbiguous) {
ConsumeParen();
bool InvalidAsDeclaration = false;
TPResult TPR = TryParseParameterDeclarationClause(&InvalidAsDeclaration);
- if (TPR == TPResult::Ambiguous()) {
+ if (TPR == TPResult::Ambiguous) {
if (Tok.isNot(tok::r_paren))
- TPR = TPResult::False();
+ TPR = TPResult::False;
else {
const Token &Next = NextToken();
if (Next.is(tok::amp) || Next.is(tok::ampamp) ||
@@ -1620,20 +1585,20 @@ bool Parser::isCXXFunctionDeclarator(bool *IsAmbiguous) {
// The next token cannot appear after a constructor-style initializer,
// and can appear next in a function definition. This must be a function
// declarator.
- TPR = TPResult::True();
+ TPR = TPResult::True;
else if (InvalidAsDeclaration)
// Use the absence of 'typename' as a tie-breaker.
- TPR = TPResult::False();
+ TPR = TPResult::False;
}
}
PA.Revert();
- if (IsAmbiguous && TPR == TPResult::Ambiguous())
+ if (IsAmbiguous && TPR == TPResult::Ambiguous)
*IsAmbiguous = true;
// In case of an error, let the declaration parsing code handle it.
- return TPR != TPResult::False();
+ return TPR != TPResult::False;
}
/// parameter-declaration-clause:
@@ -1658,7 +1623,7 @@ Parser::TryParseParameterDeclarationClause(bool *InvalidAsDeclaration,
bool VersusTemplateArgument) {
if (Tok.is(tok::r_paren))
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
// parameter-declaration-list[opt] '...'[opt]
// parameter-declaration-list ',' '...'
@@ -1672,15 +1637,15 @@ Parser::TryParseParameterDeclarationClause(bool *InvalidAsDeclaration,
if (Tok.is(tok::ellipsis)) {
ConsumeToken();
if (Tok.is(tok::r_paren))
- return TPResult::True(); // '...)' is a sign of a function declarator.
+ return TPResult::True; // '...)' is a sign of a function declarator.
else
- return TPResult::False();
+ return TPResult::False;
}
// An attribute-specifier-seq here is a sign of a function declarator.
if (isCXX11AttributeSpecifier(/*Disambiguate*/false,
/*OuterMightBeMessageSend*/true))
- return TPResult::True();
+ return TPResult::True;
ParsedAttributes attrs(AttrFactory);
MaybeParseMicrosoftAttributes(attrs);
@@ -1688,43 +1653,43 @@ Parser::TryParseParameterDeclarationClause(bool *InvalidAsDeclaration,
// decl-specifier-seq
// A parameter-declaration's initializer must be preceded by an '=', so
// decl-specifier-seq '{' is not a parameter in C++11.
- TPResult TPR = isCXXDeclarationSpecifier(TPResult::False(),
+ TPResult TPR = isCXXDeclarationSpecifier(TPResult::False,
InvalidAsDeclaration);
- if (VersusTemplateArgument && TPR == TPResult::True()) {
+ if (VersusTemplateArgument && TPR == TPResult::True) {
// Consume the decl-specifier-seq. We have to look past it, since a
// type-id might appear here in a template argument.
bool SeenType = false;
do {
SeenType |= isCXXDeclarationSpecifierAType();
- if (TryConsumeDeclarationSpecifier() == TPResult::Error())
- return TPResult::Error();
+ if (TryConsumeDeclarationSpecifier() == TPResult::Error)
+ return TPResult::Error;
// If we see a parameter name, this can't be a template argument.
if (SeenType && Tok.is(tok::identifier))
- return TPResult::True();
+ return TPResult::True;
- TPR = isCXXDeclarationSpecifier(TPResult::False(),
+ TPR = isCXXDeclarationSpecifier(TPResult::False,
InvalidAsDeclaration);
- if (TPR == TPResult::Error())
+ if (TPR == TPResult::Error)
return TPR;
- } while (TPR != TPResult::False());
- } else if (TPR == TPResult::Ambiguous()) {
+ } while (TPR != TPResult::False);
+ } else if (TPR == TPResult::Ambiguous) {
// Disambiguate what follows the decl-specifier.
- if (TryConsumeDeclarationSpecifier() == TPResult::Error())
- return TPResult::Error();
+ if (TryConsumeDeclarationSpecifier() == TPResult::Error)
+ return TPResult::Error;
} else
return TPR;
// declarator
// abstract-declarator[opt]
TPR = TryParseDeclarator(true/*mayBeAbstract*/);
- if (TPR != TPResult::Ambiguous())
+ if (TPR != TPResult::Ambiguous)
return TPR;
// [GNU] attributes[opt]
if (Tok.is(tok::kw___attribute))
- return TPResult::True();
+ return TPResult::True;
// If we're disambiguating a template argument in a default argument in
// a class definition versus a parameter declaration, an '=' here
@@ -1737,37 +1702,36 @@ Parser::TryParseParameterDeclarationClause(bool *InvalidAsDeclaration,
// parameter-declaration-clause, and the last param is missing its default
// argument.
if (VersusTemplateArgument)
- return (Tok.is(tok::equal) || Tok.is(tok::r_paren)) ? TPResult::True()
- : TPResult::False();
+ return (Tok.is(tok::equal) || Tok.is(tok::r_paren)) ? TPResult::True
+ : TPResult::False;
if (Tok.is(tok::equal)) {
// '=' assignment-expression
// Parse through assignment-expression.
// FIXME: assignment-expression may contain an unparenthesized comma.
if (!SkipUntil(tok::comma, tok::r_paren, StopAtSemi | StopBeforeMatch))
- return TPResult::Error();
+ return TPResult::Error;
}
if (Tok.is(tok::ellipsis)) {
ConsumeToken();
if (Tok.is(tok::r_paren))
- return TPResult::True(); // '...)' is a sign of a function declarator.
+ return TPResult::True; // '...)' is a sign of a function declarator.
else
- return TPResult::False();
+ return TPResult::False;
}
- if (Tok.isNot(tok::comma))
+ if (!TryConsumeToken(tok::comma))
break;
- ConsumeToken(); // the comma.
}
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
/// TryParseFunctionDeclarator - We parsed a '(' and we want to try to continue
/// parsing as a function declarator.
/// If TryParseFunctionDeclarator fully parsed the function declarator, it will
-/// return TPResult::Ambiguous(), otherwise it will return either False() or
+/// return TPResult::Ambiguous, otherwise it will return either False() or
/// Error().
///
/// '(' parameter-declaration-clause ')' cv-qualifier-seq[opt]
@@ -1781,15 +1745,15 @@ Parser::TPResult Parser::TryParseFunctionDeclarator() {
// The '(' is already parsed.
TPResult TPR = TryParseParameterDeclarationClause();
- if (TPR == TPResult::Ambiguous() && Tok.isNot(tok::r_paren))
- TPR = TPResult::False();
+ if (TPR == TPResult::Ambiguous && Tok.isNot(tok::r_paren))
+ TPR = TPResult::False;
- if (TPR == TPResult::False() || TPR == TPResult::Error())
+ if (TPR == TPResult::False || TPR == TPResult::Error)
return TPR;
// Parse through the parens.
if (!SkipUntil(tok::r_paren, StopAtSemi))
- return TPResult::Error();
+ return TPResult::Error;
// cv-qualifier-seq
while (Tok.is(tok::kw_const) ||
@@ -1805,12 +1769,12 @@ Parser::TPResult Parser::TryParseFunctionDeclarator() {
if (Tok.is(tok::kw_throw)) {
ConsumeToken();
if (Tok.isNot(tok::l_paren))
- return TPResult::Error();
+ return TPResult::Error;
// Parse through the parens after 'throw'.
ConsumeParen();
if (!SkipUntil(tok::r_paren, StopAtSemi))
- return TPResult::Error();
+ return TPResult::Error;
}
if (Tok.is(tok::kw_noexcept)) {
ConsumeToken();
@@ -1819,11 +1783,11 @@ Parser::TPResult Parser::TryParseFunctionDeclarator() {
// Find the matching rparen.
ConsumeParen();
if (!SkipUntil(tok::r_paren, StopAtSemi))
- return TPResult::Error();
+ return TPResult::Error;
}
}
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}
/// '[' constant-expression[opt] ']'
@@ -1831,7 +1795,7 @@ Parser::TPResult Parser::TryParseFunctionDeclarator() {
Parser::TPResult Parser::TryParseBracketDeclarator() {
ConsumeBracket();
if (!SkipUntil(tok::r_square, StopAtSemi))
- return TPResult::Error();
+ return TPResult::Error;
- return TPResult::Ambiguous();
+ return TPResult::Ambiguous;
}