================
@@ -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);
----------------
AaronBallman wrote:
> Do you think that there could be non 0 Loc.offset value when FID is invalid?
Maybe yes, in two ways. 1) for normal compilation paths, I'm not 100% sure but
I thought we use a memory buffer for things defined on the command line, so
that would have an invalid file ID but potentially have a nonzero offset, but I
could be remembering incorrectly. That's a case worth testing. 2) calls to the
function happening within a debugger when the state of things may not be
correct (e.g., someone is trying to debug a modules bug where the file ID isn't
properly loaded for some reason and now they get odd behavior because it's a
valid source location entry.)
It may be worth checking a blame to see whether this is intentional behavior we
were checking for or whether this was someone being defensive. If it's
defensive coding, then I think your changes make sense; but if this is
intentional, it'd be good to understand the situation.
https://github.com/llvm/llvm-project/pull/166236
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits