diff --git a/clang/include/clang/AST/ASTTypeTraits.h b/clang/include/clang/AST/ASTTypeTraits.h --- a/clang/include/clang/AST/ASTTypeTraits.h +++ b/clang/include/clang/AST/ASTTypeTraits.h @@ -296,6 +296,9 @@ /// Dumps the node to the given output stream. void dump(llvm::raw_ostream &OS, const ASTContext &Context) const; + /// Dumps the node to \c llvm::errs(). + void dump() const; + /// For nodes which represent textual entities in the source code, /// return their SourceRange. For all other nodes, return SourceRange(). SourceRange getSourceRange() const; diff --git a/clang/lib/AST/ASTTypeTraits.cpp b/clang/lib/AST/ASTTypeTraits.cpp --- a/clang/lib/AST/ASTTypeTraits.cpp +++ b/clang/lib/AST/ASTTypeTraits.cpp @@ -213,6 +213,18 @@ OS << "Unable to dump values of type " << NodeKind.asStringRef() << "\n"; } +void DynTypedNode::dump() const { + if (const Decl *D = get()) + D->dump(); + else if (const Stmt *S = get()) + S->dump(); + else if (const Type *T = get()) + T->dump(); + else + llvm::errs() << "Unable to dump values of type " << NodeKind.asStringRef() + << "\n"; +} + SourceRange DynTypedNode::getSourceRange() const { if (const CXXCtorInitializer *CCI = get()) return CCI->getSourceRange();