[PATCH] D52721: [Preprocessor] Fix a crash when handling non-alpha include header.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 1 07:03:17 PDT 2018


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lib/Lex/PPDirectives.cpp:1895
+        auto CorrectTypoFilename = [](llvm::StringRef Filename) {
+          while (!Filename.empty() && !isAlphanumeric(Filename.front())) {
+            Filename = Filename.drop_front();
----------------
`Filename = Filename.drop_until(isAlphanumeric)`

(unfortunately there's no equivalent "back" version)




================
Comment at: lib/Lex/PPDirectives.cpp:1898
+          }
+          if (Filename.empty())
+            return Filename;
----------------
simplify the logic by merging with the while loop? (and drop the assert)


================
Comment at: lib/Lex/PPDirectives.cpp:1909
+        File = Filename.empty()
+                   ? nullptr
+                   : LookupFile(FilenameLoc,
----------------
if this early bail-out isn't necessary, please drop it - it's optimizing an extremely uncommon case


Repository:
  rC Clang

https://reviews.llvm.org/D52721





More information about the cfe-commits mailing list