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

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 15 15:26:11 PDT 2017


ahatanak added inline comments.


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


================
Comment at: lib/Parse/ParseObjc.cpp:3674
+
+  // Clean up the remaining EOF token.
+  if (Tok.is(tok::eof) && Tok.getEofData() == MCDecl)
----------------
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D34185





More information about the cfe-commits mailing list