Merge pull request #81809 from hamishknight/range-expansion

[SourceKit] Properly handle cursor info range for macro expansions
This commit is contained in:
Hamish Knight
2025-05-29 20:23:54 +01:00
committed by GitHub
4 changed files with 79 additions and 35 deletions

View File

@@ -434,10 +434,18 @@ public:
/// \c nullptr if the source location isn't in this module.
SourceFile *getSourceFileContainingLocation(SourceLoc loc);
// Retrieve the buffer ID and source range of the outermost node that
// caused the generation of the buffer containing \p range. \p range and its
// buffer if it isn't in a generated buffer or has no original range.
std::pair<unsigned, SourceRange> getOriginalRange(SourceRange range) const;
// Retrieve the buffer ID and source location of the outermost location that
// caused the generation of the buffer containing \p loc. \p loc and its
// buffer if it isn't in a generated buffer or has no original location.
std::pair<unsigned, SourceLoc> getOriginalLocation(SourceLoc loc) const;
std::pair<unsigned, SourceLoc> getOriginalLocation(SourceLoc loc) const {
auto [buffer, range] = getOriginalRange(loc);
return std::make_pair(buffer, range.Start);
}
/// Creates a map from \c #filePath strings to corresponding \c #fileID
/// strings, diagnosing any conflicts.