-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang] Fix the for statement disappearing in AST when an error occurs in the conditional expression of the for statement #65381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -2158,8 +2158,10 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { | |||
// for-range-declaration next. | |||
bool MightBeForRangeStmt = !ForRangeInfo.ParsedForRangeDecl(); | |||
ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt); | |||
SourceLocation SecondPartStart = Tok.getLocation(); | |||
Sema::ConditionKind CK = Sema::ConditionKind::Boolean; | |||
SecondPart = ParseCXXCondition( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use ParseParenExprOrCondition
here? but it may need to extend the parameters of ParseParenExprOrCondition
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me but I would like another set of eyes on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo @shafik's feedback
4a94f9b
to
712eb69
Compare
29c7599
to
7225074
Compare
…occurs in the conditional expression of the for statement
Co-authored-by: Shafik Yaghmour <shafik@users.noreply.github.com>
7225074
to
be9e6aa
Compare
Consider:
The AST before this patch:
The AST after this patch: