<< Keyword << SourceRange(UnavailableLoc);
}
UnavailableLoc = KeywordLoc;
-
- if (TryConsumeToken(tok::comma))
- continue;
- break;
+ continue;
}
if (Tok.isNot(tok::equal)) {
<< Keyword << VersionRange;
}
- if (Tok.isNot(tok::comma))
- break;
-
- ConsumeToken();
- } while (true);
+ } while (TryConsumeToken(tok::comma));
// Closing ')'.
if (T.consumeClose())
return;
}
IdentifierLoc *RelatedClass = ParseIdentifierLoc();
- if (!TryConsumeToken(tok::comma)) {
- Diag(Tok, diag::err_expected) << tok::comma;
+ if (ExpectAndConsume(tok::comma)) {
SkipUntil(tok::r_paren, StopAtSemi);
return;
}
// Ignore optional 'typename'.
// FIXME: This is wrong; we should parse this as a typename-specifier.
- if (Tok.is(tok::kw_typename)) {
- TypenameLoc = ConsumeToken();
+ if (TryConsumeToken(tok::kw_typename, TypenameLoc))
HasTypenameKeyword = true;
- }
// Parse nested-name-specifier.
IdentifierInfo *LastII = 0;
// If the next token is a comma, consume it and keep reading
// base-specifiers.
- if (Tok.isNot(tok::comma)) break;
-
- // Consume the comma.
- ConsumeToken();
+ if (!TryConsumeToken(tok::comma))
+ break;
}
// Attach the base specifiers
MaybeParseCXX11Attributes(Attributes);
// Parse the 'virtual' keyword.
- if (Tok.is(tok::kw_virtual)) {
- ConsumeToken();
+ if (TryConsumeToken(tok::kw_virtual))
IsVirtual = true;
- }
CheckMisplacedCXX11Attribute(Attributes, StartLoc);
// actually part of the base-specifier-list grammar productions, but we
// parse it here for convenience.
SourceLocation EllipsisLoc;
- if (Tok.is(tok::ellipsis))
- EllipsisLoc = ConsumeToken();
-
+ TryConsumeToken(tok::ellipsis, EllipsisLoc);
+
// Find the complete source range for the base-specifier.
SourceRange Range(StartLoc, EndLocation);
if (!DeclaratorInfo.hasName()) {
// If so, skip until the semi-colon or a }.
SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
- if (Tok.is(tok::semi))
- ConsumeToken();
+ TryConsumeToken(tok::semi);
return;
}
// declarator pure-specifier[opt]
// declarator brace-or-equal-initializer[opt]
// identifier[opt] ':' constant-expression
- if (Tok.is(tok::colon)) {
- ConsumeToken();
+ if (TryConsumeToken(tok::colon)) {
BitfieldSize = ParseConstantExpression();
if (BitfieldSize.isInvalid())
SkipUntil(tok::comma, StopAtSemi | StopBeforeMatch);
T.consumeClose();
SourceLocation EllipsisLoc;
- if (Tok.is(tok::ellipsis))
- EllipsisLoc = ConsumeToken();
+ TryConsumeToken(tok::ellipsis, EllipsisLoc);
return Actions.ActOnMemInitializer(ConstructorDecl, getCurScope(), SS, II,
TemplateTypeTy, DS, IdLoc,
Exceptions.push_back(Res.get());
Ranges.push_back(Range);
}
-
- if (Tok.is(tok::comma))
- ConsumeToken();
- else
+
+ if (!TryConsumeToken(tok::comma))
break;
}
while (Tok.isNot(tok::r_square)) {
// attribute not present
- if (Tok.is(tok::comma)) {
- ConsumeToken();
+ if (TryConsumeToken(tok::comma))
continue;
- }
SourceLocation ScopeLoc, AttrLoc;
IdentifierInfo *ScopeName = 0, *AttrName = 0;
break;
// scoped attribute
- if (Tok.is(tok::coloncolon)) {
- ConsumeToken();
-
+ if (TryConsumeToken(tok::coloncolon)) {
ScopeName = AttrName;
ScopeLoc = AttrLoc;
AttrLoc),
ScopeName, ScopeLoc, 0, 0, AttributeList::AS_CXX11);
- if (Tok.is(tok::ellipsis)) {
- ConsumeToken();
-
+ if (TryConsumeToken(tok::ellipsis))
Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis)
<< AttrName->getName();
- }
}
if (ExpectAndConsume(tok::r_square))
}
// If we reached this code, the statement must end in a semicolon.
- if (Tok.is(tok::semi)) {
- ConsumeToken();
- } else if (!Res.isInvalid()) {
+ if (!TryConsumeToken(tok::semi) && !Res.isInvalid()) {
// If the result was valid, then we do want to diagnose this. Use
// ExpectAndConsume to emit the diagnostic, even though we know it won't
// succeed.
ColonProtection.restore();
if (TryConsumeToken(tok::colon, ColonLoc)) {
- // Treat "case blah;" as a typo for "case blah:".
} else if (TryConsumeToken(tok::semi, ColonLoc)) {
+ // Treat "case blah;" as a typo for "case blah:".
Diag(ColonLoc, diag::err_expected_after)
<< "'case'" << tok::colon
<< FixItHint::CreateReplacement(ColonLoc, ":");
SourceLocation ColonLoc;
if (TryConsumeToken(tok::colon, ColonLoc)) {
- // Treat "default;" as a typo for "default:".
} else if (TryConsumeToken(tok::semi, ColonLoc)) {
+ // Treat "default;" as a typo for "default:".
Diag(ColonLoc, diag::err_expected_after)
<< "'default'" << tok::colon
<< FixItHint::CreateReplacement(ColonLoc, ":");
Clobbers.push_back(Clobber.release());
- if (Tok.isNot(tok::comma)) break;
- ConsumeToken();
+ if (!TryConsumeToken(tok::comma))
+ break;
}
}
}
}
Exprs.push_back(Res.release());
// Eat the comma and continue parsing if it exists.
- if (Tok.isNot(tok::comma)) return false;
- ConsumeToken();
+ if (!TryConsumeToken(tok::comma))
+ return false;
}
}
return TPResult::True();
}
- if (Tok.isNot(tok::comma))
+ if (!TryConsumeToken(tok::comma))
break;
- ConsumeToken(); // the comma.
}
return TPResult::Ambiguous();
}
}
- if (Tok.is(tok::ellipsis))
- ConsumeToken();
+ TryConsumeToken(tok::ellipsis);
- if (Tok.isNot(tok::comma))
+ if (!TryConsumeToken(tok::comma))
break;
-
- ConsumeToken();
}
// An attribute must end ']]'.
return TPResult::False();
}
- if (Tok.isNot(tok::comma))
+ if (!TryConsumeToken(tok::comma))
break;
- ConsumeToken(); // the comma.
}
return TPResult::Ambiguous();