[PATCH] D130847: [clang] SourceManager: fix at SourceManager::getFileIDLoaded for the case of invalid SLockEntry
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 9 05:23:39 PDT 2022
aaron.ballman added inline comments.
================
Comment at: clang/lib/Basic/SourceManager.cpp:882-884
const SrcMgr::SLocEntry &E = getLoadedSLocEntry(I);
+ if (E.getOffset() == 0)
+ return FileID(); // invalid entry.
----------------
This looks incorrect to me -- I don't think an offset of `0` is invalid. I think a better way to do this is:
```
bool Invalid;
const SrcMgr::SLocEntry &E = getLoadedSLocEntry(I, &Invalid);
if (Invalid)
return FileID(); // Invalid entry.
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130847/new/
https://reviews.llvm.org/D130847
More information about the cfe-commits
mailing list