summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-03-18 17:23:41 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-24 15:37:20 (GMT)
commit2ccf3b840d595a2dcc154358d9effc0a93f5606b (patch)
tree43f39e324e14a16bb90a41a2762e11c39f51f677
parentff2e71572682d0ccfffd40a19ff259bb0c1f723b (diff)
downloadCastXML-2ccf3b840d595a2dcc154358d9effc0a93f5606b.zip
CastXML-2ccf3b840d595a2dcc154358d9effc0a93f5606b.tar.gz
CastXML-2ccf3b840d595a2dcc154358d9effc0a93f5606b.tar.bz2
Output: Add bases="" attribute to Class elements
The gccxml output format originally reported bases as an attribute of <Class> elements and later added the <Base> nested elements to produce valid XML IDREFs and indicate virtual inheritance. We need to include the old bases="" attribute to match the gccxml format.
-rw-r--r--src/Output.cxx27
-rw-r--r--test/expect/gccxml.Class-bases-xml.txt2
-rw-r--r--test/expect/gccxml.Class-template-bases-xml.txt2
-rw-r--r--test/expect/gccxml.using-declaration-class-xml.txt2
4 files changed, 30 insertions, 3 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index 856a79b..9bb14c6 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -241,6 +241,11 @@ class ASTVisitor: public ASTVisitorBase
context members for later output. */
void PrintMembersAttribute(clang::DeclContext const* dc);
+ /** Print a bases="..." attribute listing the XML IDREFs for
+ bases of the given class type. Also queues the base classes
+ for later output. */
+ void PrintBasesAttribute(clang::CXXRecordDecl const* dx);
+
/** Print a throws="..." attribute listing the XML IDREFs for
the types that the given function prototype declares in
the throw() specification. */
@@ -863,6 +868,25 @@ void ASTVisitor::PrintMembersAttribute(clang::DeclContext const* dc)
}
//----------------------------------------------------------------------------
+void ASTVisitor::PrintBasesAttribute(clang::CXXRecordDecl const* dx)
+{
+ this->OS << " bases=\"";
+ const char* sep = "";
+ for(clang::CXXRecordDecl::base_class_const_iterator i = dx->bases_begin(),
+ e = dx->bases_end(); i != e; ++i) {
+ this->OS << sep;
+ sep = " ";
+ switch (i->getAccessSpecifier()) {
+ case clang::AS_private: this->OS << "private:"; break;
+ case clang::AS_protected: this->OS << "protected:"; break;
+ default: break;
+ }
+ this->PrintTypeIdRef(i->getType(), true);
+ }
+ this->OS << "\"";
+}
+
+//----------------------------------------------------------------------------
void ASTVisitor::PrintThrowsAttribute(clang::FunctionProtoType const* fpt,
bool complete)
{
@@ -1070,6 +1094,9 @@ void ASTVisitor::OutputRecordDecl(clang::RecordDecl const* d,
if(dn->Complete) {
this->PrintMembersAttribute(d);
doBases = dx && dx->getNumBases();
+ if(doBases) {
+ this->PrintBasesAttribute(dx);
+ }
this->PrintBefriendingAttribute(dx);
}
} else {
diff --git a/test/expect/gccxml.Class-bases-xml.txt b/test/expect/gccxml.Class-bases-xml.txt
index 2a18228..f650a84 100644
--- a/test/expect/gccxml.Class-bases-xml.txt
+++ b/test/expect/gccxml.Class-bases-xml.txt
@@ -1,6 +1,6 @@
^<\?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">
+ <Class id="_1" name="start" context="_2" location="f1:4" file="f1" line="4" members="_3 _4 _5 _6" bases="_7 private:_8 protected:_9">
<Base type="_7" access="public" virtual="0"/>
<Base type="_8" access="private" virtual="0"/>
<Base type="_9" access="protected" virtual="1"/>
diff --git a/test/expect/gccxml.Class-template-bases-xml.txt b/test/expect/gccxml.Class-template-bases-xml.txt
index c89fba6..332f7c0 100644
--- a/test/expect/gccxml.Class-template-bases-xml.txt
+++ b/test/expect/gccxml.Class-template-bases-xml.txt
@@ -1,6 +1,6 @@
^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
- <Class id="_1" name="start&lt;int&gt;" context="_2" location="f1:4" file="f1" line="4" members="_3 _4 _5 _6">
+ <Class id="_1" name="start&lt;int&gt;" context="_2" location="f1:4" file="f1" line="4" members="_3 _4 _5 _6" bases="_7 _8">
<Base type="_7" access="public" virtual="0"/>
<Base type="_8" access="public" virtual="0"/>
</Class>
diff --git a/test/expect/gccxml.using-declaration-class-xml.txt b/test/expect/gccxml.using-declaration-class-xml.txt
index 08d4188..4ba114d 100644
--- a/test/expect/gccxml.using-declaration-class-xml.txt
+++ b/test/expect/gccxml.using-declaration-class-xml.txt
@@ -1,6 +1,6 @@
^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
- <Class id="_1" name="start" context="_2" location="f1:5" file="f1" line="5" members="_3 _4 _5 _6 _7 _8">
+ <Class id="_1" name="start" context="_2" location="f1:5" file="f1" line="5" members="_3 _4 _5 _6 _7 _8" bases="_9">
<Base type="_9" access="public" virtual="0"/>
</Class>
<Method id="_3" name="f" returns="_10" context="_9" access="protected" location="f1:3" file="f1" line="3">