@@ -120,6 +120,27 @@ class SwiftDispatcher {
120120 locatableLabel);
121121 }
122122
123+ // return `std::optional(fetchLabel(arg))` if arg converts to true, otherwise std::nullopt
124+ template <typename Arg>
125+ auto fetchOptionalLabel (Arg&& arg)
126+ -> std::optional<decltype(fetchLabel(std::forward<Arg>(arg)))> {
127+ if (arg) {
128+ return fetchLabel (std::forward<Arg>(arg));
129+ }
130+ return std::nullopt ;
131+ }
132+
133+ // map `fetchLabel` on the iterable `arg`, returning a vector of all labels
134+ template <typename Iterable>
135+ auto fetchRepeatedLabels (Iterable&& arg) -> std::vector<decltype(fetchLabel(*arg.begin()))> {
136+ std::vector<decltype (fetchLabel (*arg.begin ()))> ret;
137+ ret.reserve (arg.size ());
138+ for (const auto & e : arg) {
139+ ret.push_back (fetchLabel (e));
140+ }
141+ return ret;
142+ }
143+
123144 private:
124145 // types to be supported by assignNewLabel/fetchLabel need to be listed here
125146 using Store = TrapLabelStore<swift::Decl,
@@ -147,7 +168,7 @@ class SwiftDispatcher {
147168 auto locLabel = createLabel<LocationTag>(' {' , fileLabel, " }:" , startLine, ' :' , startColumn, ' :' ,
148169 endLine, ' :' , endColumn);
149170 trap.emit (LocationsTrap{locLabel, fileLabel, startLine, startColumn, endLine, endColumn});
150- trap.emit (LocatablesTrap {locatableLabel, locLabel});
171+ trap.emit (LocatableLocationsTrap {locatableLabel, locLabel});
151172 }
152173
153174 template <typename Tag, typename ... Ts>
0 commit comments