Skip to content

Commit 143b510

Browse files
committed
[Clang] Fix asan error after ad1a65f
Annotating tokens can invalid the stack of Peaked tokens.
1 parent ec402a2 commit 143b510

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

clang/lib/Parse/ParseExpr.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
10651065
if (getLangOpts().CPlusPlus) {
10661066
// Avoid the unnecessary parse-time lookup in the common case
10671067
// where the syntax forbids a type.
1068-
const Token &Next = NextToken();
1068+
Token Next = NextToken();
10691069

10701070
if (Next.is(tok::ellipsis) && Tok.is(tok::identifier) &&
10711071
GetLookAheadToken(2).is(tok::l_square)) {
@@ -1081,9 +1081,8 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
10811081
// If this identifier was reverted from a token ID, and the next token
10821082
// is a parenthesis, this is likely to be a use of a type trait. Check
10831083
// those tokens.
1084-
if (Next.is(tok::l_paren) &&
1085-
Tok.is(tok::identifier) &&
1086-
Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
1084+
else if (Next.is(tok::l_paren) && Tok.is(tok::identifier) &&
1085+
Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
10871086
IdentifierInfo *II = Tok.getIdentifierInfo();
10881087
// Build up the mapping of revertible type traits, for future use.
10891088
if (RevertibleTypeTraits.empty()) {
@@ -1170,9 +1169,9 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
11701169
}
11711170
}
11721171

1173-
if ((!ColonIsSacred && Next.is(tok::colon)) ||
1174-
Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
1175-
tok::l_brace)) {
1172+
else if ((!ColonIsSacred && Next.is(tok::colon)) ||
1173+
Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
1174+
tok::l_brace)) {
11761175
// If TryAnnotateTypeOrScopeToken annotates the token, tail recurse.
11771176
if (TryAnnotateTypeOrScopeToken())
11781177
return ExprError();

0 commit comments

Comments
 (0)