This patch ensures that the typo fixit for the @try/@finally/@autoreleasepool { } directive is shown only when we're parsing an actual statement where such directives can actually be present.
Details
- Reviewers
bruno manmanren - Commits
- rGa589abc35346: [ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression
rC288334: [ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression
rL288334: [ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression
Diff Detail
- Repository
- rL LLVM
Event Timeline
Hi Alex, thanks for working on this
lib/Parse/ParseObjc.cpp | ||
---|---|---|
2877 ↗ | (On Diff #78728) | Does this only triggers when Res.isInvalid() returns true in the first part of the patch? I wonder if it's also safe to allow ExprStatementTokLoc = AtLoc; for every path or only when it fails. |
lib/Parse/ParseObjc.cpp | ||
---|---|---|
2877 ↗ | (On Diff #78728) | Yes, this code will always flow to the body of the if with Res.isInvalid, but only after this code is executed, so we need to set ExprStatementTokLoc before the check for Res.isInvalid. As well as that, all users of ExprStatementTokLoc currently care only about the current location where the current statement is being parsed (they check to see if some expression location matches it), so it should be set before a method call like ParseExpressionWithLeadingAt, and it doesn't have to be cleared as the next statement will have a different location anyway. So it seems safe to set ExprStatementTokLoc = AtLoc as it follows the intended convention. |