Skip to content

Commit 6f22102

Browse files
authored
Merge pull request #59996 from ahoppen/pr/more-dumping
Support dumping of null ASTNodes and ConstraintLocatorBuilder
2 parents 98ba11f + 6416640 commit 6f22102

File tree

3 files changed

+367
-322
lines changed

3 files changed

+367
-322
lines changed

include/swift/Sema/ConstraintLocator.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ class ConstraintLocator : public llvm::FoldingSetNode {
191191
bool isClosureResult() const {
192192
return getKind() == PathElementKind::ClosureResult;
193193
}
194+
195+
void dump(raw_ostream &out) const LLVM_ATTRIBUTE_USED;
196+
SWIFT_DEBUG_DUMP {
197+
dump(llvm::errs());
198+
}
194199
};
195200

196201
/// Return the summary flags for an entire path.
@@ -1256,6 +1261,12 @@ class ConstraintLocatorBuilder {
12561261

12571262
return None;
12581263
}
1264+
1265+
/// Produce a debugging dump of this locator.
1266+
SWIFT_DEBUG_DUMPER(dump(SourceManager *SM));
1267+
SWIFT_DEBUG_DUMPER(dump(ConstraintSystem *CS));
1268+
1269+
void dump(SourceManager *SM, raw_ostream &OS) const LLVM_ATTRIBUTE_USED;
12591270
};
12601271

12611272
} // end namespace constraints

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)