Skip to content

Commit 8f74eb0

Browse files
committed
Make Node::addChild(NULL, ...) always assert.
We need this in order to gather relevant information when this situation arises; it's clearly happening (e.g. rdar://86071019), but not often enough for it to trigger in a build with assertions enabled. rdar://89139049
1 parent 94c0e52 commit 8f74eb0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Demangling/Demangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Node::iterator Node::end() const {
336336
}
337337

338338
void Node::addChild(NodePointer Child, NodeFactory &Factory) {
339-
assert(Child);
339+
DEMANGLER_ALWAYS_ASSERT(Child, this);
340340
switch (NodePayloadKind) {
341341
case PayloadKind::None:
342342
InlineChildren[0] = Child;

lib/Demangling/DemanglerAssert.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242

4343
#endif // SWIFT_RUNTIME || defined(NDEBUG)
4444

45+
// DEMANGLER_ALWAYS_ASSERT() *always* fails the program, even in the runtime
46+
#define DEMANGLER_ALWAYS_ASSERT(expr, node) \
47+
do { \
48+
if (!(expr)) \
49+
swift::Demangle::failAssert(__FILE__, __LINE__, node, #expr); \
50+
} while (0)
51+
4552
namespace swift {
4653
namespace Demangle {
4754
SWIFT_BEGIN_INLINE_NAMESPACE

0 commit comments

Comments
 (0)