Skip to content

Commit 5f47252

Browse files
committed
[AST] Don’t crash when dumping null ASTNodes
1 parent ab6faa9 commit 5f47252

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/AST/ASTNode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ void ASTNode::walk(ASTWalker &Walker) {
109109
}
110110

111111
void ASTNode::dump(raw_ostream &OS, unsigned Indent) const {
112-
if (auto S = dyn_cast<Stmt*>())
112+
if (isNull())
113+
OS << "(null)";
114+
else if (auto S = dyn_cast<Stmt*>())
113115
S->dump(OS, /*context=*/nullptr, Indent);
114116
else if (auto E = dyn_cast<Expr*>())
115117
E->dump(OS, Indent);

0 commit comments

Comments
 (0)