Skip to content

Commit

Permalink
Implements getFullyOriginalRange (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
suzizecat authored Sep 15, 2024
1 parent 1010137 commit b2cf6ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/slang/text/SourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class SLANG_EXPORT SourceManager {
/// inside a macro. Otherwise just returns the location itself.
SourceLocation getFullyOriginalLoc(SourceLocation location) const;

/// Build the original location range where source is written.
/// If there is a mismatch between resulting start and end files,
/// returns the original range instead.
SourceRange getFullyOriginalRange(SourceRange range) const;

/// If the given location is a macro location, fully expands it out to its actual
/// file expansion location. Otherwise just returns the location itself.
SourceLocation getFullyExpandedLoc(SourceLocation location) const;
Expand Down
6 changes: 6 additions & 0 deletions source/text/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ SourceLocation SourceManager::getFullyOriginalLoc(SourceLocation location) const
return location;
}

SourceRange SourceManager::getFullyOriginalRange(SourceRange range) const {
SourceLocation start(getFullyOriginalLoc(range.start()));
SourceLocation end(getFullyOriginalLoc(range.end()));
return SourceRange(start, end);
}

SourceLocation SourceManager::getFullyExpandedLoc(SourceLocation location) const {
std::shared_lock lock(mutex);
return getFullyExpandedLocImpl(location, lock);
Expand Down

0 comments on commit b2cf6ae

Please sign in to comment.