Switch GeneratedSourceInfo ranges over to CharSourceRange.

Macro expansion buffers, along with other generated source buffers,
need more precise "original source ranges" that can be had with the
token-based `SourceRange`. Switch over to `CharSourceRange` and provide
more thoughtfully-determined original source ranges.
This commit is contained in:
Doug Gregor
2023-02-10 22:38:38 -08:00
parent 7ebc86e584
commit 7ea0e3f096
11 changed files with 117 additions and 40 deletions

View File

@@ -918,11 +918,11 @@ static void setLocationInfo(const ValueDecl *VD,
// function body and which we created while reusing the ASTContext for
// the rest of the file. Map the location back to the original file.
unsigned OriginalBufID = SM.findBufferContainingLoc(
GeneratedSourceInfo->originalSourceRange.Start);
GeneratedSourceInfo->originalSourceRange.getStart());
auto OriginalStartOffset = SM.getLocOffsetInBuffer(
GeneratedSourceInfo->originalSourceRange.Start, OriginalBufID);
GeneratedSourceInfo->originalSourceRange.getStart(), OriginalBufID);
auto GeneratedStartOffset = SM.getLocOffsetInBuffer(
GeneratedSourceInfo->generatedSourceRange.Start, DeclBufID);
GeneratedSourceInfo->generatedSourceRange.getStart(), DeclBufID);
Location.Offset += OriginalStartOffset - GeneratedStartOffset;
assert(SM.findBufferContainingLoc(Loc) == DeclBufID);
std::tie(Location.Line, Location.Column) =