[PATCH] D130847: [clang] SourceManager: fix at SourceManager::getFileIDLoaded for the case of invalid SLockEntry

Ivan Murashko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 9 05:56:29 PDT 2022


ivanmurashko 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.
----------------
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)?


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