summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichka Popoff <michkapopoff@gmail.com>2015-03-31 21:23:06 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-08 14:30:21 (GMT)
commit57c93dfba8395299cd939c40dd894f40cfd4ec28 (patch)
tree23208094ee267ab21e548a98ecc00ed985a29d51
parent4402138958fac4e9eae008d8987aa2f14278d272 (diff)
downloadCastXML-57c93dfba8395299cd939c40dd894f40cfd4ec28.zip
CastXML-57c93dfba8395299cd939c40dd894f40cfd4ec28.tar.gz
CastXML-57c93dfba8395299cd939c40dd894f40cfd4ec28.tar.bz2
Output: Generate an "offset" attribute on Field elements
This information is produced by gccxml, so add it to our output too.
-rw-r--r--src/Output.cxx10
-rw-r--r--test/expect/gccxml.any.Class-implicit-member-access-mutable.xml.txt2
-rw-r--r--test/expect/gccxml.any.Class-implicit-member-array.xml.txt2
-rw-r--r--test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt2
-rw-r--r--test/expect/gccxml.any.Class-implicit-member-const.xml.txt2
-rw-r--r--test/expect/gccxml.any.Class-implicit-member-reference.xml.txt2
-rw-r--r--test/expect/gccxml.any.Field.xml.txt6
-rw-r--r--test/expect/gccxml.any.GNU-float128.xml.txt2
-rw-r--r--test/expect/gccxml.c89.GNU-float128.xml.txt2
9 files changed, 20 insertions, 10 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index c50a4b2..e1a5e05 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -230,6 +230,9 @@ class ASTVisitor: public ASTVisitorBase
void PrintNameAttribute(std::string const& name);
void PrintNameAttribute(clang::NamedDecl const* d);
+ /** Print an offset="..." attribute. */
+ void PrintOffsetAttribute(unsigned int const& offset);
+
/** Print a basetype="..." attribute with the XML IDREF for
the given type. Also queues the given type for later output. */
void PrintBaseTypeAttribute(clang::Type const* c, bool complete);
@@ -907,6 +910,12 @@ void ASTVisitor::PrintNameAttribute(clang::NamedDecl const* d)
}
//----------------------------------------------------------------------------
+void ASTVisitor::PrintOffsetAttribute(unsigned int const& offset)
+{
+ this->OS << " offset=\"" << offset << "\"";
+}
+
+//----------------------------------------------------------------------------
void ASTVisitor::PrintBaseTypeAttribute(clang::Type const* c, bool complete)
{
this->OS << " basetype=\"";
@@ -1381,6 +1390,7 @@ void ASTVisitor::OutputFieldDecl(clang::FieldDecl const* d, DumpNode const* dn)
}
this->PrintContextAttribute(d);
this->PrintLocationAttribute(d);
+ this->PrintOffsetAttribute(this->CTX.getFieldOffset(d));
if(d->isMutable()) {
this->OS << " mutable=\"1\"";
}
diff --git a/test/expect/gccxml.any.Class-implicit-member-access-mutable.xml.txt b/test/expect/gccxml.any.Class-implicit-member-access-mutable.xml.txt
index 2b41827..b7d51d2 100644
--- a/test/expect/gccxml.any.Class-implicit-member-access-mutable.xml.txt
+++ b/test/expect/gccxml.any.Class-implicit-member-access-mutable.xml.txt
@@ -14,7 +14,7 @@
<OperatorMethod id="_9" name="=" returns="_12" context="_5" access="private" location="f1:7" file="f1" line="7">
<Argument type="_11" location="f1:7" file="f1" line="7"/>
</OperatorMethod>
- <Field id="_10" name="data" type="_13" context="_5" access="private" location="f1:8" file="f1" line="8" mutable="1"/>
+ <Field id="_10" name="data" type="_13" context="_5" access="private" location="f1:8" file="f1" line="8" offset="0" mutable="1"/>
<ReferenceType id="_11" type="_5c"/>
<ReferenceType id="_12" type="_5"/>
<FundamentalType id="_13" name="int"/>
diff --git a/test/expect/gccxml.any.Class-implicit-member-array.xml.txt b/test/expect/gccxml.any.Class-implicit-member-array.xml.txt
index 82ecfa2..5e43cd8 100644
--- a/test/expect/gccxml.any.Class-implicit-member-array.xml.txt
+++ b/test/expect/gccxml.any.Class-implicit-member-array.xml.txt
@@ -1,7 +1,7 @@
^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
<Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6 _7"/>
- <Field id="_3" name="data" type="_8" context="_1" access="private" location="f1:2" file="f1" line="2"/>
+ <Field id="_3" name="data" type="_8" context="_1" access="private" location="f1:2" file="f1" line="2" offset="0"/>
<Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?/>
<Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?>
<Argument type="_9" location="f1:1" file="f1" line="1"/>
diff --git a/test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt b/test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt
index 35aec14..51970b7 100644
--- a/test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt
+++ b/test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt
@@ -10,7 +10,7 @@
<Destructor id="_5" name="start" context="_1" access="public" location="f1:9" file="f1" line="9" inline="1" artificial="1"( throws="")?/>
<Class id="_6" name="base&lt;const int&gt;" context="_2" location="f1:1" file="f1" line="1" members="_8 _9 _10 _11"/>
<ReferenceType id="_7" type="_1c"/>
- <Field id="_8" name="data" type="_14c" context="_6" access="protected" location="f1:3" file="f1" line="3"/>
+ <Field id="_8" name="data" type="_14c" context="_6" access="protected" location="f1:3" file="f1" line="3" offset="0"/>
<Constructor id="_9" name="base" context="_6" access="protected" location="f1:4" file="f1" line="4"/>
<Constructor id="_10" name="base" context="_6" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?>
<Argument type="_15" location="f1:1" file="f1" line="1"/>
diff --git a/test/expect/gccxml.any.Class-implicit-member-const.xml.txt b/test/expect/gccxml.any.Class-implicit-member-const.xml.txt
index a609d0c..8d31e8f 100644
--- a/test/expect/gccxml.any.Class-implicit-member-const.xml.txt
+++ b/test/expect/gccxml.any.Class-implicit-member-const.xml.txt
@@ -1,7 +1,7 @@
^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
<Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6"/>
- <Field id="_3" name="data" type="_8c" context="_1" access="private" location="f1:2" file="f1" line="2"/>
+ <Field id="_3" name="data" type="_8c" context="_1" access="private" location="f1:2" file="f1" line="2" offset="0"/>
<Constructor id="_4" name="start" context="_1" access="public" location="f1:4" file="f1" line="4"/>
<Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?>
<Argument type="_9" location="f1:1" file="f1" line="1"/>
diff --git a/test/expect/gccxml.any.Class-implicit-member-reference.xml.txt b/test/expect/gccxml.any.Class-implicit-member-reference.xml.txt
index 37921f7..9581777 100644
--- a/test/expect/gccxml.any.Class-implicit-member-reference.xml.txt
+++ b/test/expect/gccxml.any.Class-implicit-member-reference.xml.txt
@@ -1,7 +1,7 @@
^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
<Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6"/>
- <Field id="_3" name="ref" type="_7" context="_1" access="private" location="f1:2" file="f1" line="2"/>
+ <Field id="_3" name="ref" type="_7" context="_1" access="private" location="f1:2" file="f1" line="2" offset="0"/>
<Constructor id="_4" name="start" context="_1" access="public" location="f1:4" file="f1" line="4"/>
<Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?>
<Argument type="_8" location="f1:1" file="f1" line="1"/>
diff --git a/test/expect/gccxml.any.Field.xml.txt b/test/expect/gccxml.any.Field.xml.txt
index ab39d48..4441641 100644
--- a/test/expect/gccxml.any.Field.xml.txt
+++ b/test/expect/gccxml.any.Field.xml.txt
@@ -1,9 +1,9 @@
^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
<Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6 _7 _8 _9"/>
- <Field id="_3" name="field" type="_10" context="_1" access="private" location="f1:2" file="f1" line="2"/>
- <Field id="_4" name="bit_field" type="_11" bits="2" context="_1" access="private" location="f1:3" file="f1" line="3"/>
- <Field id="_5" name="mutable_field" type="_10" context="_1" access="private" location="f1:4" file="f1" line="4" mutable="1"/>
+ <Field id="_3" name="field" type="_10" context="_1" access="private" location="f1:2" file="f1" line="2" offset="0"/>
+ <Field id="_4" name="bit_field" type="_11" bits="2" context="_1" access="private" location="f1:3" file="f1" line="3" offset="32"/>
+ <Field id="_5" name="mutable_field" type="_10" context="_1" access="private" location="f1:4" file="f1" line="4" offset="64" mutable="1"/>
<Constructor id="_6" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?>
<Argument type="_12" location="f1:1" file="f1" line="1"/>
</Constructor>
diff --git a/test/expect/gccxml.any.GNU-float128.xml.txt b/test/expect/gccxml.any.GNU-float128.xml.txt
index 61b11fa..26f4080 100644
--- a/test/expect/gccxml.any.GNU-float128.xml.txt
+++ b/test/expect/gccxml.any.GNU-float128.xml.txt
@@ -5,7 +5,7 @@
</Function>
<Typedef id="_2" name="__float128" type="_4" context="_3"/>
<Struct id="_4" name="" context="_3" members="_5 _6 _7 _8 _9"/>
- <Field id="_5" name="x" type="_10" context="_4" access="public"/>
+ <Field id="_5" name="x" type="_10" context="_4" access="public" offset="0"/>
<Constructor id="_6" context="_4" access="public" location="f0:0" file="f0" line="0" inline="1" artificial="1"( throws="")?/>
<Constructor id="_7" context="_4" access="public" location="f0:0" file="f0" line="0" inline="1" artificial="1"( throws="")?>
<Argument type="_11"/>
diff --git a/test/expect/gccxml.c89.GNU-float128.xml.txt b/test/expect/gccxml.c89.GNU-float128.xml.txt
index 8195cff..7c800e7 100644
--- a/test/expect/gccxml.c89.GNU-float128.xml.txt
+++ b/test/expect/gccxml.c89.GNU-float128.xml.txt
@@ -5,7 +5,7 @@
</Function>
<Typedef id="_2" name="__float128" type="_4" context="_3"/>
<Struct id="_4" name="" context="_3" members="_5"/>
- <Field id="_5" name="x" type="_6" context="_4" access="public"/>
+ <Field id="_5" name="x" type="_6" context="_4" access="public" offset="0"/>
<ArrayType id="_6" min="0" max="15" type="_7"/>
<FundamentalType id="_7" name="char"/>
<Namespace id="_3" name="::"/>