[clang] [clang] Delete duplicate code in sourcemanager (PR #166236)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 4 08:31:24 PST 2025
================
@@ -1275,43 +1275,24 @@ class SourceManager : public RefCountedBase<SourceManager> {
/// start of the buffer of the location.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const {
FileID FID = getFileID(Loc);
- auto *Entry = getSLocEntryOrNull(FID);
- if (!Entry)
- return std::make_pair(FileID(), 0);
- return std::make_pair(FID, Loc.getOffset() - Entry->getOffset());
+ const SrcMgr::SLocEntry &Entry = getSLocEntry(FID);
----------------
SergejSalnikov wrote:
getSLocEntry already handles the invalid FID. and returns a predefined entry.
Do you think that there could be non 0 Loc.offset value when FID is invalid?
https://github.com/llvm/llvm-project/pull/166236
More information about the cfe-commits
mailing list