diff options
author | Brad King <brad.king@kitware.com> | 2014-03-04 21:10:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-21 21:14:49 (GMT) |
commit | 5669ced871bbe3d74e9742ea6bb45b11fc5c8a57 (patch) | |
tree | 9d26f9ef88a1f34e1c2b6eb6df3810bf4b703c8d | |
parent | 543da18510aa8dbfe901bd371c95f3d0f7bf06d6 (diff) | |
download | CastXML-5669ced871bbe3d74e9742ea6bb45b11fc5c8a57.zip CastXML-5669ced871bbe3d74e9742ea6bb45b11fc5c8a57.tar.gz CastXML-5669ced871bbe3d74e9742ea6bb45b11fc5c8a57.tar.bz2 |
Output: Report class bases
Inside Class elements generate Base elements reporting the type="",
access="", and virtual="" information about base classes, if any.
-rw-r--r-- | src/Output.cxx | 17 | ||||
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/expect/gccxml.Class-bases-xml.txt | 57 | ||||
-rw-r--r-- | test/input/Class-bases.cxx | 9 |
4 files changed, 83 insertions, 1 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index 605a96f..f12103b 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -1015,6 +1015,7 @@ void ASTVisitor::OutputRecordDecl(clang::RecordDecl const* d, case clang::TTK_Enum: return; } clang::CXXRecordDecl const* dx = clang::dyn_cast<clang::CXXRecordDecl>(d); + bool doBases = false; this->OS << " <" << tag; this->PrintIdAttribute(dn); @@ -1029,11 +1030,25 @@ void ASTVisitor::OutputRecordDecl(clang::RecordDecl const* d, } if(dn->Complete) { this->PrintMembersAttribute(d); + doBases = dx && dx->getNumBases(); } } else { this->OS << " incomplete=\"1\""; } - this->OS << "/>\n"; + if(doBases) { + this->OS << ">\n"; + for(clang::CXXRecordDecl::base_class_const_iterator i = dx->bases_begin(), + e = dx->bases_end(); i != e; ++i) { + this->OS << " <Base"; + this->PrintTypeAttribute(i->getType(), true); + this->PrintAccessAttribute(i->getAccessSpecifier()); + this->OS << " virtual=\"" << (i->isVirtual()? 1 : 0) << "\""; + this->OS << "/>\n"; + } + this->OS << " </" << tag << ">\n"; + } else { + this->OS << "/>\n"; + } } //---------------------------------------------------------------------------- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8dc4201..7ed3a96 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -69,6 +69,7 @@ castxml_test_gccxml(ArrayType) castxml_test_gccxml(ArrayType-incomplete) castxml_test_gccxml(Class) castxml_test_gccxml(Class-abstract) +castxml_test_gccxml(Class-bases) castxml_test_gccxml(Class-incomplete) castxml_test_gccxml(Class-template) castxml_test_gccxml(CvQualifiedType) diff --git a/test/expect/gccxml.Class-bases-xml.txt b/test/expect/gccxml.Class-bases-xml.txt new file mode 100644 index 0000000..2a18228 --- /dev/null +++ b/test/expect/gccxml.Class-bases-xml.txt @@ -0,0 +1,57 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Class id="_1" name="start" context="_2" location="f1:4" file="f1" line="4" members="_3 _4 _5 _6"> + <Base type="_7" access="public" virtual="0"/> + <Base type="_8" access="private" virtual="0"/> + <Base type="_9" access="protected" virtual="1"/> + </Class> + <OperatorMethod id="_3" name="=" returns="_10" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"> + <Argument type="_11" location="f1:4" file="f1" line="4"/> + </OperatorMethod> + <Destructor id="_4" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"/> + <Constructor id="_5" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"/> + <Constructor id="_6" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"> + <Argument type="_11" location="f1:4" file="f1" line="4"/> + </Constructor> + <Class id="_7" name="base_public" context="_2" location="f1:1" file="f1" line="1" members="_12 _13 _14 _15"/> + <Class id="_8" name="base_private" context="_2" location="f1:2" file="f1" line="2" members="_16 _17 _18 _19"/> + <Class id="_9" name="base_protected" context="_2" location="f1:3" file="f1" line="3" members="_20 _21 _22 _23"/> + <ReferenceType id="_10" type="_1"/> + <ReferenceType id="_11" type="_1c"/> + <Constructor id="_12" name="base_public" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"/> + <Constructor id="_13" name="base_public" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"> + <Argument type="_25" location="f1:1" file="f1" line="1"/> + </Constructor> + <OperatorMethod id="_14" name="=" returns="_26" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"> + <Argument type="_25" location="f1:1" file="f1" line="1"/> + </OperatorMethod> + <Destructor id="_15" name="base_public" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"/> + <Constructor id="_16" name="base_private" context="_8" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"/> + <Constructor id="_17" name="base_private" context="_8" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"> + <Argument type="_27" location="f1:2" file="f1" line="2"/> + </Constructor> + <OperatorMethod id="_18" name="=" returns="_28" context="_8" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"> + <Argument type="_27" location="f1:2" file="f1" line="2"/> + </OperatorMethod> + <Destructor id="_19" name="base_private" context="_8" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"/> + <Constructor id="_20" name="base_protected" context="_9" access="public" location="f1:3" file="f1" line="3" inline="1" artificial="1"/> + <Constructor id="_21" name="base_protected" context="_9" access="public" location="f1:3" file="f1" line="3" inline="1" artificial="1"> + <Argument type="_29" location="f1:3" file="f1" line="3"/> + </Constructor> + <OperatorMethod id="_22" name="=" returns="_30" context="_9" access="public" location="f1:3" file="f1" line="3" inline="1" artificial="1"> + <Argument type="_29" location="f1:3" file="f1" line="3"/> + </OperatorMethod> + <Destructor id="_23" name="base_protected" context="_9" access="public" location="f1:3" file="f1" line="3" inline="1" artificial="1"/> + <ReferenceType id="_25" type="_7c"/> + <ReferenceType id="_26" type="_7"/> + <ReferenceType id="_27" type="_8c"/> + <ReferenceType id="_28" type="_8"/> + <ReferenceType id="_29" type="_9c"/> + <ReferenceType id="_30" type="_9"/> + <Namespace id="_2" name="::"/> + <CvQualifiedType id="_7c" type="_7" const="1"/> + <CvQualifiedType id="_8c" type="_8" const="1"/> + <CvQualifiedType id="_9c" type="_9" const="1"/> + <CvQualifiedType id="_1c" type="_1" const="1"/> + <File id="f1" name=".*/test/input/Class-bases.cxx"/> +</GCC_XML>$ diff --git a/test/input/Class-bases.cxx b/test/input/Class-bases.cxx new file mode 100644 index 0000000..5e37d14 --- /dev/null +++ b/test/input/Class-bases.cxx @@ -0,0 +1,9 @@ +class base_public {}; +class base_private {}; +class base_protected {}; +class start: + public base_public, + private base_private, + virtual protected base_protected +{ +}; |