Skip to content

Commit 63f5a86

Browse files
authored
Merge pull request github#9264 from github/redsun82/swift-fix-ndebug-build
Swift: fix extractor built with `NDEBUG`
2 parents bf958ff + ea6a249 commit 63f5a86

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)