diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-08 18:51:03 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-08 18:51:03 +0000 |
commit | 8a16769b61c77ebc6682435db2ed1823ae1be0f1 (patch) | |
tree | 0e2addf66e13483617ce34588560ec8ad3a6ba91 /clang/lib/Frontend/DeclXML.cpp | |
parent | dac58bd094bb771d972ad221c0a8ba1c5f403988 (diff) | |
download | bcm5719-llvm-8a16769b61c77ebc6682435db2ed1823ae1be0f1.tar.gz bcm5719-llvm-8a16769b61c77ebc6682435db2ed1823ae1be0f1.zip |
Improve XML output for C++ classes, from Olaf Krzikalla!
llvm-svn: 97954
Diffstat (limited to 'clang/lib/Frontend/DeclXML.cpp')
-rw-r--r-- | clang/lib/Frontend/DeclXML.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/clang/lib/Frontend/DeclXML.cpp b/clang/lib/Frontend/DeclXML.cpp index d7470d92a94..8750b1efcab 100644 --- a/clang/lib/Frontend/DeclXML.cpp +++ b/clang/lib/Frontend/DeclXML.cpp @@ -29,6 +29,14 @@ class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter> { } } + void addFunctionBody(FunctionDecl* FD) { + if (FD->isThisDeclarationADefinition()) { + Doc.addSubNode("Body"); + Doc.PrintStmt(FD->getBody()); + Doc.toParent(); + } + } + void addSubNodes(RecordDecl* RD) { for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end(); i != e; ++i) { @@ -37,6 +45,15 @@ class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter> { } } + void addSubNodes(CXXRecordDecl* RD) { + addSubNodes(cast<RecordDecl>(RD)); + for (CXXRecordDecl::method_iterator i = RD->method_begin(), + e = RD->method_end(); i != e; ++i) { + Visit(*i); + Doc.toParent(); + } + } + void addSubNodes(EnumDecl* ED) { for (EnumDecl::enumerator_iterator i = ED->enumerator_begin(), e = ED->enumerator_end(); i != e; ++i) { @@ -115,6 +132,8 @@ public: #define SUB_NODE_SEQUENCE_XML( CLASS ) addSubNodes(T); #define SUB_NODE_OPT_XML( CLASS ) addSubNodes(T); +#define SUB_NODE_FN_BODY_XML addFunctionBody(T); + #include "clang/Frontend/DeclXML.def" }; @@ -122,13 +141,6 @@ public: //--------------------------------------------------------- void DocumentXML::writeDeclToXML(Decl *D) { DeclPrinter(*this).Visit(D); - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { - if (Stmt *Body = FD->getBody()) { - addSubNode("Body"); - PrintStmt(Body); - toParent(); - } - } toParent(); } |