@@ -78,7 +78,7 @@ class SwiftDispatcher {
7878 waitingForNewLabel = e;
7979 visit (e);
8080 if (auto l = store.get (e)) {
81- if constexpr (! std::is_base_of_v<swift::TypeBase, E >) {
81+ if constexpr (std::is_base_of_v<LocatableTag, TrapTagOf<E> >) {
8282 attachLocation (e, *l);
8383 }
8484 return *l;
@@ -95,6 +95,10 @@ class SwiftDispatcher {
9595 return fetchLabelFromUnion<AstNodeTag>(node);
9696 }
9797
98+ TrapLabel<IfConfigClauseTag> fetchLabel (const swift::IfConfigClause& clause) {
99+ return fetchLabel (&clause);
100+ }
101+
98102 // Due to the lazy emission approach, we must assign a label to a corresponding AST node before
99103 // it actually gets emitted to handle recursive cases such as recursive calls, or recursive type
100104 // declarations
@@ -143,6 +147,15 @@ class SwiftDispatcher {
143147 attachLocation (locatable->getStartLoc (), locatable->getEndLoc (), locatableLabel);
144148 }
145149
150+ void attachLocation (const swift::IfConfigClause* clause, TrapLabel<LocatableTag> locatableLabel) {
151+ attachLocation (clause->Loc , clause->Loc , locatableLabel);
152+ }
153+
154+ // Emits a Location TRAP entry and attaches it to a `Locatable` trap label for a given `SourceLoc`
155+ void attachLocation (swift::SourceLoc loc, TrapLabel<LocatableTag> locatableLabel) {
156+ attachLocation (loc, loc, locatableLabel);
157+ }
158+
146159 // Emits a Location TRAP entry for a list of swift entities and attaches it to a `Locatable` trap
147160 // label
148161 template <typename Locatable>
@@ -217,7 +230,8 @@ class SwiftDispatcher {
217230 swift::Expr,
218231 swift::Pattern,
219232 swift::TypeRepr,
220- swift::TypeBase>;
233+ swift::TypeBase,
234+ swift::IfConfigClause>;
221235
222236 void attachLocation (swift::SourceLoc start,
223237 swift::SourceLoc end,
@@ -274,6 +288,7 @@ class SwiftDispatcher {
274288 // TODO: The following methods are supposed to redirect TRAP emission to correpsonding visitors,
275289 // which are to be introduced in follow-up PRs
276290 virtual void visit (swift::Decl* decl) = 0;
291+ virtual void visit (const swift::IfConfigClause* clause) = 0;
277292 virtual void visit (swift::Stmt* stmt) = 0;
278293 virtual void visit (swift::StmtCondition* cond) = 0;
279294 virtual void visit (swift::CaseLabelItem* item) = 0;
0 commit comments