Skip to content

Commit 386dedb

Browse files
committed
Swift: fix location extractor hitting swift assertion
1 parent c17a582 commit 386dedb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

swift/extractor/infra/SwiftLocationExtractor.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ concept HasSourceRangeOnly = requires(T e) {
4040
&&(!HasStartAndEndLoc<T>)&&(!HasOneLoc<T>);
4141

4242
swift::SourceRange getSourceRange(const HasStartAndEndLoc auto& locatable) {
43-
return {locatable.getStartLoc(), locatable.getEndLoc()};
43+
if (locatable.getStartLoc() && locatable.getEndLoc()) {
44+
return {locatable.getStartLoc(), locatable.getEndLoc()};
45+
}
46+
return {};
4447
}
4548

4649
swift::SourceRange getSourceRange(const HasOneLoc auto& locatable) {
@@ -64,7 +67,10 @@ swift::SourceRange getSourceRange(const llvm::MutableArrayRef<Locatable>& locata
6467
}
6568
auto startRange = getSourceRange(locatables.front());
6669
auto endRange = getSourceRange(locatables.back());
67-
return {startRange.Start, endRange.End};
70+
if (startRange.Start && endRange.End) {
71+
return {startRange.Start, endRange.End};
72+
}
73+
return {};
6874
}
6975
} // namespace detail
7076

0 commit comments

Comments
 (0)