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 {
175175 CODEQL_ASSERT (found != store.end (), " createEntry called on non-fetched label" );
176176 using Tag = ConcreteTrapTagOf<E>;
177177 auto label = TrapLabel<Tag>::unsafeCreateFromUntyped (found->second );
178- if constexpr (requires { locationExtractor. attachLocation (sourceManager, e, label); } ) {
178+ if constexpr (IsLocatable<E> ) {
179179 locationExtractor.attachLocation (sourceManager, e, label);
180180 }
181181 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
5959 auto endRange = getSourceRange (locatables.back ());
6060 return {startRange.Start , endRange.End };
6161}
62-
63- // default case, no location
64- swift::SourceRange getSourceRange (const auto &) {
65- return {};
66- }
6762} // namespace detail
6863
64+ template <typename E>
65+ concept IsLocatable = requires (E e) { detail::getSourceRange (e); };
66+
6967class SwiftLocationExtractor {
7068 public:
7169 explicit SwiftLocationExtractor (TrapDomain& trap) : trap(trap) {}
@@ -75,13 +73,13 @@ class SwiftLocationExtractor {
7573
7674 // Emits a Location TRAP entry and attaches it to a `Locatable` trap label
7775 void attachLocation (const swift::SourceManager& sourceManager,
78- const auto & locatable,
76+ const IsLocatable auto & locatable,
7977 TrapLabel<LocatableTag> locatableLabel) {
8078 attachLocationImpl (sourceManager, detail::getSourceRange (locatable), locatableLabel);
8179 }
8280
8381 void attachLocation (const swift::SourceManager& sourceManager,
84- const auto * locatable,
82+ const IsLocatable auto * locatable,
8583 TrapLabel<LocatableTag> locatableLabel) {
8684 attachLocation (sourceManager, *locatable, locatableLabel);
8785 }
You can’t perform that action at this time.
0 commit comments