[PATCH] D130847: [clang] SourceManager: fix isOffsetInFileID for the case of a fake SLocEntry
Ivan Murashko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 31 13:59:33 PDT 2022
ivanmurashko updated this revision to Diff 448885.
ivanmurashko added a comment.
rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130847/new/
https://reviews.llvm.org/D130847
Files:
clang/include/clang/Basic/SourceManager.h
Index: clang/include/clang/Basic/SourceManager.h
===================================================================
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -1825,7 +1825,13 @@
/// specified SourceLocation offset. This is a very hot method.
inline bool isOffsetInFileID(FileID FID,
SourceLocation::UIntTy SLocOffset) const {
- const SrcMgr::SLocEntry &Entry = getSLocEntry(FID);
+ bool Invalid = false;
+ const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid);
+
+ // If the entry is invalid, it can't contain it.
+ if (Invalid)
+ return false;
+
// If the entry is after the offset, it can't contain it.
if (SLocOffset < Entry.getOffset()) return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130847.448885.patch
Type: text/x-patch
Size: 787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220731/37ba8b7e/attachment.bin>
More information about the cfe-commits
mailing list