Skip to content

Commit ea6a249

Browse files
committed
Swift: fix extractor built with NDEBUG
There was a call with side effects in an `assert`, that was therefore not being called with `NDEBUG` turned on, changing extractor results.
1 parent bf958ff commit ea6a249

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

swift/extractor/SwiftDispatcher.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ class SwiftDispatcher {
153153
template <typename Tag, typename... Ts>
154154
TrapLabel<Tag> fetchLabelFromUnion(const llvm::PointerUnion<Ts...> u) {
155155
TrapLabel<Tag> ret{};
156-
assert((... || fetchLabelFromUnionCase<Tag, Ts>(u, ret)) && "llvm::PointerUnion not set");
156+
// with logical op short-circuiting, this will stop trying on the first successful fetch
157+
// don't feel tempted to replace the variable with the expression inside the `assert`, or
158+
// building with `NDEBUG` will not trigger the fetching
159+
bool unionCaseFound = (... || fetchLabelFromUnionCase<Tag, Ts>(u, ret));
160+
assert(unionCaseFound && "llvm::PointerUnion not set to a known case");
157161
return ret;
158162
}
159163

0 commit comments

Comments
 (0)