[cfe-dev] [cfg-dev] A more flexible dump method for Stmt
Zhenbo Xu
zhenbo1987 at gmail.com
Sun Jun 17 03:49:58 PDT 2012
Hi, everyone!
When I try to dump a Stmt to my own raw_ostream for debugging, the existing
"dump" methods need parameter SourceManager that is hard to be obtained. So
I think the new dump function in the following annotated diff would be
useful.
Index: include/clang/AST/Stmt.h
===================================================================
--- include/clang/AST/Stmt.h (revision 158485)
+++ include/clang/AST/Stmt.h (working copy)
@@ -363,6 +363,7 @@
/// This is useful in a debugger.
LLVM_ATTRIBUTE_USED void dump() const;
LLVM_ATTRIBUTE_USED void dump(SourceManager &SM) const;
+ void dump(raw_ostream &OS) const;
void dump(raw_ostream &OS, SourceManager &SM) const;
/// dumpAll - This does a dump of the specified AST fragment and all
subtrees.
Index: lib/AST/StmtDumper.cpp
===================================================================
--- lib/AST/StmtDumper.cpp (revision 158485)
+++ lib/AST/StmtDumper.cpp (working copy)
@@ -744,6 +744,12 @@
llvm::errs() << "\n";
}
+void Stmt::dump(raw_ostream &OS) const {
+ StmtDumper P(0, OS, 4);
+ P.DumpSubTree(const_cast<Stmt*>(this));
+ OS << "\n";
+}
+
/// dumpAll - This does a dump of the specified AST fragment and all
subtrees.
void Stmt::dumpAll(SourceManager &SM) const {
StmtDumper P(&SM, llvm::errs(), ~0U);
--
Zhenbo Xu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120617/851a5931/attachment.html>
More information about the cfe-dev
mailing list