[PATCH] D34185: [Parser][ObjC] Avoid crashing when skipping to EOF while parsing an ObjC interface/implementation

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 19 04:30:48 PDT 2017


arphaman marked an inline comment as done.
arphaman added inline comments.


================
Comment at: lib/Parse/ParseObjc.cpp:220
   CheckNestedObjCContexts(AtLoc);
+  if (isEofOrEom())
+    return nullptr;
----------------
ahatanak wrote:
> Do you need this check here (and below)?
Not anymore. Thanks!


================
Comment at: lib/Parse/ParseObjc.cpp:3674
+
+  // Clean up the remaining EOF token.
+  if (Tok.is(tok::eof) && Tok.getEofData() == MCDecl)
----------------
ahatanak wrote:
> I think you want to clean up the EOF token after the code below which skips the leftover tokens, regardless of whether Tok is EOF. You can do it unconditionally since Tok.getLocation() == OrigLoc and you know the token is the EOF inserted above.
Good point. Thanks for noticing!


Repository:
  rL LLVM

https://reviews.llvm.org/D34185





More information about the cfe-commits mailing list