mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Swift: fix location extractor hitting swift assertion
This commit is contained in:
@@ -40,7 +40,10 @@ concept HasSourceRangeOnly = requires(T e) {
|
|||||||
&&(!HasStartAndEndLoc<T>)&&(!HasOneLoc<T>);
|
&&(!HasStartAndEndLoc<T>)&&(!HasOneLoc<T>);
|
||||||
|
|
||||||
swift::SourceRange getSourceRange(const HasStartAndEndLoc auto& locatable) {
|
swift::SourceRange getSourceRange(const HasStartAndEndLoc auto& locatable) {
|
||||||
return {locatable.getStartLoc(), locatable.getEndLoc()};
|
if (locatable.getStartLoc() && locatable.getEndLoc()) {
|
||||||
|
return {locatable.getStartLoc(), locatable.getEndLoc()};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
swift::SourceRange getSourceRange(const HasOneLoc auto& locatable) {
|
swift::SourceRange getSourceRange(const HasOneLoc auto& locatable) {
|
||||||
@@ -64,7 +67,10 @@ swift::SourceRange getSourceRange(const llvm::MutableArrayRef<Locatable>& locata
|
|||||||
}
|
}
|
||||||
auto startRange = getSourceRange(locatables.front());
|
auto startRange = getSourceRange(locatables.front());
|
||||||
auto endRange = getSourceRange(locatables.back());
|
auto endRange = getSourceRange(locatables.back());
|
||||||
return {startRange.Start, endRange.End};
|
if (startRange.Start && endRange.End) {
|
||||||
|
return {startRange.Start, endRange.End};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user