[PATCH] D26916: [ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 02:51:51 PST 2016


arphaman added inline comments.


================
Comment at: lib/Parse/ParseObjc.cpp:2877
+        if (GetLookAheadToken(1).is(tok::l_brace) &&
+            ExprStatementTokLoc == AtLoc) {
           char ch = Tok.getIdentifierInfo()->getNameStart()[0];
----------------
bruno wrote:
> 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.
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D26916





More information about the cfe-commits mailing list