forked from OSchip/llvm-project
Improve XML output for C++ classes, from Olaf Krzikalla!
llvm-svn: 97954
This commit is contained in:
parent
dac58bd094
commit
8a16769b61
|
@ -103,7 +103,7 @@ NODE_XML(FunctionDecl, "Function")
|
||||||
//ATTRIBUTE_OPT_XML(isVariadic(), "variadic") // in the type reference
|
//ATTRIBUTE_OPT_XML(isVariadic(), "variadic") // in the type reference
|
||||||
ATTRIBUTE_XML(getNumParams(), "num_args")
|
ATTRIBUTE_XML(getNumParams(), "num_args")
|
||||||
SUB_NODE_SEQUENCE_XML(ParmVarDecl)
|
SUB_NODE_SEQUENCE_XML(ParmVarDecl)
|
||||||
//SUB_NODE_OPT_XML("Body")
|
SUB_NODE_FN_BODY_XML
|
||||||
END_NODE_XML
|
END_NODE_XML
|
||||||
|
|
||||||
NODE_XML(CXXMethodDecl, "CXXMethodDecl")
|
NODE_XML(CXXMethodDecl, "CXXMethodDecl")
|
||||||
|
@ -118,13 +118,9 @@ NODE_XML(CXXMethodDecl, "CXXMethodDecl")
|
||||||
ATTRIBUTE_OPT_XML(isVirtual(), "virtual")
|
ATTRIBUTE_OPT_XML(isVirtual(), "virtual")
|
||||||
ATTRIBUTE_XML(getNumParams(), "num_args")
|
ATTRIBUTE_XML(getNumParams(), "num_args")
|
||||||
SUB_NODE_SEQUENCE_XML(ParmVarDecl)
|
SUB_NODE_SEQUENCE_XML(ParmVarDecl)
|
||||||
//SUB_NODE_OPT_XML("Body")
|
SUB_NODE_FN_BODY_XML
|
||||||
END_NODE_XML
|
END_NODE_XML
|
||||||
|
|
||||||
//NODE_XML("Body")
|
|
||||||
// SUB_NODE_XML(Stmt)
|
|
||||||
//END_NODE_XML
|
|
||||||
|
|
||||||
NODE_XML(NamespaceDecl, "Namespace")
|
NODE_XML(NamespaceDecl, "Namespace")
|
||||||
ID_ATTRIBUTE_XML
|
ID_ATTRIBUTE_XML
|
||||||
ATTRIBUTE_FILE_LOCATION_XML
|
ATTRIBUTE_FILE_LOCATION_XML
|
||||||
|
@ -156,6 +152,16 @@ NODE_XML(RecordDecl, "Record")
|
||||||
SUB_NODE_SEQUENCE_XML(FieldDecl)
|
SUB_NODE_SEQUENCE_XML(FieldDecl)
|
||||||
END_NODE_XML
|
END_NODE_XML
|
||||||
|
|
||||||
|
NODE_XML(CXXRecordDecl, "CXXRecord")
|
||||||
|
ID_ATTRIBUTE_XML
|
||||||
|
ATTRIBUTE_FILE_LOCATION_XML
|
||||||
|
ATTRIBUTE_XML(getDeclContext(), "context")
|
||||||
|
ATTRIBUTE_XML(getNameAsString(), "name")
|
||||||
|
ATTRIBUTE_OPT_XML(isDefinition() == false, "forward")
|
||||||
|
ATTRIBUTE_XML(getTypeForDecl(), "type") // refers to the type this decl creates
|
||||||
|
SUB_NODE_SEQUENCE_XML(FieldDecl)
|
||||||
|
END_NODE_XML
|
||||||
|
|
||||||
NODE_XML(EnumDecl, "Enum")
|
NODE_XML(EnumDecl, "Enum")
|
||||||
ID_ATTRIBUTE_XML
|
ID_ATTRIBUTE_XML
|
||||||
ATTRIBUTE_FILE_LOCATION_XML
|
ATTRIBUTE_FILE_LOCATION_XML
|
||||||
|
@ -248,3 +254,4 @@ END_NODE_XML
|
||||||
#undef SUB_NODE_XML
|
#undef SUB_NODE_XML
|
||||||
#undef SUB_NODE_SEQUENCE_XML
|
#undef SUB_NODE_SEQUENCE_XML
|
||||||
#undef SUB_NODE_OPT_XML
|
#undef SUB_NODE_OPT_XML
|
||||||
|
#undef SUB_NODE_FN_BODY_XML
|
||||||
|
|
|
@ -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) {
|
void addSubNodes(RecordDecl* RD) {
|
||||||
for (RecordDecl::field_iterator i = RD->field_begin(),
|
for (RecordDecl::field_iterator i = RD->field_begin(),
|
||||||
e = RD->field_end(); i != e; ++i) {
|
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) {
|
void addSubNodes(EnumDecl* ED) {
|
||||||
for (EnumDecl::enumerator_iterator i = ED->enumerator_begin(),
|
for (EnumDecl::enumerator_iterator i = ED->enumerator_begin(),
|
||||||
e = ED->enumerator_end(); i != e; ++i) {
|
e = ED->enumerator_end(); i != e; ++i) {
|
||||||
|
@ -115,6 +132,8 @@ public:
|
||||||
#define SUB_NODE_SEQUENCE_XML( CLASS ) addSubNodes(T);
|
#define SUB_NODE_SEQUENCE_XML( CLASS ) addSubNodes(T);
|
||||||
#define SUB_NODE_OPT_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"
|
#include "clang/Frontend/DeclXML.def"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,13 +141,6 @@ public:
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
void DocumentXML::writeDeclToXML(Decl *D) {
|
void DocumentXML::writeDeclToXML(Decl *D) {
|
||||||
DeclPrinter(*this).Visit(D);
|
DeclPrinter(*this).Visit(D);
|
||||||
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
|
|
||||||
if (Stmt *Body = FD->getBody()) {
|
|
||||||
addSubNode("Body");
|
|
||||||
PrintStmt(Body);
|
|
||||||
toParent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toParent();
|
toParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue