[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:15:35 PDT 2018
sammccall added inline comments.
================
Comment at: lib/Lex/PPDirectives.cpp:1898
+ }
+ if (Filename.empty())
+ return Filename;
----------------
kristina wrote:
> sammccall wrote:
> > simplify the logic by merging with the while loop? (and drop the assert)
> I thought the assert was a good idea in case a similar issue popped up again (somehow triggering this but in reverse, not sure if that makes sense), it's a no-op in upstream release builds anyway.
`while (!empty && !isAlpha(back)) { drop_back }`
is just as safe, and easier to understand than
```
// ... subtly establish that there is an alphanum in the string ...
while (!isAlpha(back)) { drop_back; assert(!empty) }
```
Repository:
rC Clang
https://reviews.llvm.org/D52721
More information about the cfe-commits
mailing list