mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: tweak location extractor using new concept
This commit is contained in:
@@ -59,13 +59,11 @@ swift::SourceRange getSourceRange(const llvm::MutableArrayRef<Locatable>& locata
|
||||
auto endRange = getSourceRange(locatables.back());
|
||||
return {startRange.Start, endRange.End};
|
||||
}
|
||||
|
||||
// default case, no location
|
||||
swift::SourceRange getSourceRange(const auto&) {
|
||||
return {};
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename E>
|
||||
concept IsLocatable = requires(E e) { detail::getSourceRange(e); };
|
||||
|
||||
class SwiftLocationExtractor {
|
||||
public:
|
||||
explicit SwiftLocationExtractor(TrapDomain& trap) : trap(trap) {}
|
||||
@@ -75,13 +73,13 @@ class SwiftLocationExtractor {
|
||||
|
||||
// Emits a Location TRAP entry and attaches it to a `Locatable` trap label
|
||||
void attachLocation(const swift::SourceManager& sourceManager,
|
||||
const auto& locatable,
|
||||
const IsLocatable auto& locatable,
|
||||
TrapLabel<LocatableTag> locatableLabel) {
|
||||
attachLocationImpl(sourceManager, detail::getSourceRange(locatable), locatableLabel);
|
||||
}
|
||||
|
||||
void attachLocation(const swift::SourceManager& sourceManager,
|
||||
const auto* locatable,
|
||||
const IsLocatable auto* locatable,
|
||||
TrapLabel<LocatableTag> locatableLabel) {
|
||||
attachLocation(sourceManager, *locatable, locatableLabel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user