[PATCH] D130847: [clang] SourceManager: fix at SourceManager::getFileIDLoaded for the case of invalid SLockEntry
Aaron Ballman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 06:08:24 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.
----------------
ivanmurashko wrote:
> aaron.ballman wrote:
> > 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.
> > ```
> That's reasonable, do we want to update other places at the function as well (line 903 for instance)?
Assuming my idea works the way I think it will, yes, I think that's a good idea. :-)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130847/new/
https://reviews.llvm.org/D130847
More information about the llvm-commits
mailing list