File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 20
20
#include " llvm/ADT/PointerUnion.h"
21
21
#include " swift/AST/TypeAlignments.h"
22
22
23
+ namespace llvm {
24
+ class raw_ostream ;
25
+ }
26
+
23
27
namespace swift {
24
28
class Expr ;
25
29
class Stmt ;
@@ -57,6 +61,11 @@ namespace swift {
57
61
FUNC (Expr)
58
62
FUNC (Decl)
59
63
#undef FUNC
64
+
65
+ LLVM_ATTRIBUTE_DEPRECATED (
66
+ void dump () const LLVM_ATTRIBUTE_USED,
67
+ "only for use within the debugger");
68
+ void dump (llvm::raw_ostream &OS, unsigned Indent = 0 ) const ;
60
69
61
70
// / Whether the AST node is implicit.
62
71
bool isImplicit () const ;
Original file line number Diff line number Diff line change @@ -77,6 +77,21 @@ void ASTNode::walk(ASTWalker &Walker) {
77
77
llvm_unreachable (" unsupported AST node" );
78
78
}
79
79
80
+ void ASTNode::dump (raw_ostream &OS, unsigned Indent) const {
81
+ if (auto S = dyn_cast<Stmt*>())
82
+ S->dump (OS, /* context=*/ nullptr , Indent);
83
+ else if (auto E = dyn_cast<Expr*>())
84
+ E->dump (OS, Indent);
85
+ else if (auto D = dyn_cast<Decl*>())
86
+ D->dump (OS, Indent);
87
+ else
88
+ OS << " <null>" ;
89
+ }
90
+
91
+ void ASTNode::dump () const {
92
+ dump (llvm::errs ());
93
+ }
94
+
80
95
#define FUNC (T ) \
81
96
bool ASTNode::is##T(T##Kind Kind) const { \
82
97
if (!is<T*>()) \
You can’t perform that action at this time.
0 commit comments