Skip to content

Commit

Permalink
[Clang] Fix asan error after ad1a65f
Browse files Browse the repository at this point in the history
Annotating tokens can invalid the stack of Peaked tokens.
  • Loading branch information
cor3ntin committed Jan 27, 2024
1 parent ec402a2 commit 143b510
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions clang/lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
if (getLangOpts().CPlusPlus) {
// Avoid the unnecessary parse-time lookup in the common case
// where the syntax forbids a type.
const Token &Next = NextToken();
Token Next = NextToken();

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

if ((!ColonIsSacred && Next.is(tok::colon)) ||
Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
tok::l_brace)) {
else if ((!ColonIsSacred && Next.is(tok::colon)) ||
Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
tok::l_brace)) {
// If TryAnnotateTypeOrScopeToken annotates the token, tail recurse.
if (TryAnnotateTypeOrScopeToken())
return ExprError();
Expand Down

0 comments on commit 143b510

Please sign in to comment.