File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ class SwiftDispatcher {
175
175
CODEQL_ASSERT (found != store.end (), " createEntry called on non-fetched label" );
176
176
using Tag = ConcreteTrapTagOf<E>;
177
177
auto label = TrapLabel<Tag>::unsafeCreateFromUntyped (found->second );
178
- if constexpr (requires { locationExtractor. attachLocation (sourceManager, e, label); } ) {
178
+ if constexpr (IsLocatable<E> ) {
179
179
locationExtractor.attachLocation (sourceManager, e, label);
180
180
}
181
181
return TrapClassOf<E>{label};
Original file line number Diff line number Diff line change @@ -59,13 +59,11 @@ swift::SourceRange getSourceRange(const llvm::MutableArrayRef<Locatable>& locata
59
59
auto endRange = getSourceRange (locatables.back ());
60
60
return {startRange.Start , endRange.End };
61
61
}
62
-
63
- // default case, no location
64
- swift::SourceRange getSourceRange (const auto &) {
65
- return {};
66
- }
67
62
} // namespace detail
68
63
64
+ template <typename E>
65
+ concept IsLocatable = requires (E e) { detail::getSourceRange (e); };
66
+
69
67
class SwiftLocationExtractor {
70
68
public:
71
69
explicit SwiftLocationExtractor (TrapDomain& trap) : trap(trap) {}
@@ -75,13 +73,13 @@ class SwiftLocationExtractor {
75
73
76
74
// Emits a Location TRAP entry and attaches it to a `Locatable` trap label
77
75
void attachLocation (const swift::SourceManager& sourceManager,
78
- const auto & locatable,
76
+ const IsLocatable auto & locatable,
79
77
TrapLabel<LocatableTag> locatableLabel) {
80
78
attachLocationImpl (sourceManager, detail::getSourceRange (locatable), locatableLabel);
81
79
}
82
80
83
81
void attachLocation (const swift::SourceManager& sourceManager,
84
- const auto * locatable,
82
+ const IsLocatable auto * locatable,
85
83
TrapLabel<LocatableTag> locatableLabel) {
86
84
attachLocation (sourceManager, *locatable, locatableLabel);
87
85
}
You can’t perform that action at this time.
0 commit comments