Skip to content

Commit d3c38bb

Browse files
committed
---
yaml --- r: 346878 b: refs/heads/master c: 384e492 h: refs/heads/master
1 parent 582b64e commit d3c38bb

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b8de9eac986930dfa162c89f6a3718617dfe7c52
2+
refs/heads/master: 384e49282a0cd7c6dc711f863587580f06a4d464
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/ASTNode.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#include "llvm/ADT/PointerUnion.h"
2121
#include "swift/AST/TypeAlignments.h"
2222

23+
namespace llvm {
24+
class raw_ostream;
25+
}
26+
2327
namespace swift {
2428
class Expr;
2529
class Stmt;
@@ -57,6 +61,11 @@ namespace swift {
5761
FUNC(Expr)
5862
FUNC(Decl)
5963
#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;
6069

6170
/// Whether the AST node is implicit.
6271
bool isImplicit() const;

trunk/lib/AST/ASTNode.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ void ASTNode::walk(ASTWalker &Walker) {
7777
llvm_unreachable("unsupported AST node");
7878
}
7979

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+
8095
#define FUNC(T) \
8196
bool ASTNode::is##T(T##Kind Kind) const { \
8297
if (!is<T*>()) \

0 commit comments

Comments
 (0)