diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-09 00:36:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-09 00:36:22 +0000 |
commit | fd8f7da224ef188f799256a6bc37c463ba0071ed (patch) | |
tree | 02efc52e5decee3beab0f62f7743902e77d2bed2 | |
parent | 6000dace22f110d8768476989313e9d981d690d0 (diff) |
Dump out types for expressions, and handle typedefs nicely.
This allows us to dump:
typedef short S;
int test(S X, long long Y) {
return X < ((100));
}
as:
typedef short S;
int test(S X, long long Y)
(CompoundStmt 0x2905d40
(ReturnStmt 0x2905d30
(BinaryOperator 0x2905d10 'int' '<'
(ImplicitCastExpr 0x2905d00 'int'
(DeclRefExpr 0x2905c80 'S':'short' Decl='X' 0x2905c20))
(ParenExpr 0x2905ce0 'int'
(ParenExpr 0x2905cc0 'int'
(IntegerLiteral 0x2905ca0 'int' 100))))))
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40956 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/StmtDumper.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/AST/StmtDumper.cpp b/AST/StmtDumper.cpp index ebff1541ca..5d288778b3 100644 --- a/AST/StmtDumper.cpp +++ b/AST/StmtDumper.cpp @@ -58,6 +58,15 @@ namespace { fprintf(F, " "); } + void DumpType(QualType T) const { + fprintf(F, "'%s'", T.getAsString().c_str()); + + // If the type is directly a typedef, strip off typedefness to give at + // least one level of concreteness. + if (TypedefType *TDT = dyn_cast<TypedefType>(T)) + fprintf(F, ":'%s'", TDT->LookThroughTypedefs().getAsString().c_str()); + } + void DumpStmt(const Stmt *Node) const { Indent(); fprintf(F, "(%s %p", Node->getStmtClassName(), (void*)Node); @@ -65,7 +74,8 @@ namespace { void DumpExpr(Expr *Node) const { DumpStmt(Node); - // TODO: DUMP TYPE + fprintf(F, " "); + DumpType(Node->getType()); } virtual void VisitStmt(Stmt *Node); |