summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-02-12 21:25:19 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-21 18:40:45 (GMT)
commit3c4ddceaaefede03146e864c5e567b20eaae6597 (patch)
tree7793bf1d0c825f37f94300d8dfebee8124b3ca38
parent8894bed3e516fcabd82a349a61fce237570aa85e (diff)
downloadCastXML-3c4ddceaaefede03146e864c5e567b20eaae6597.zip
CastXML-3c4ddceaaefede03146e864c5e567b20eaae6597.tar.gz
CastXML-3c4ddceaaefede03146e864c5e567b20eaae6597.tar.bz2
Output: Generate ArrayType elements
Implement the OutputConstantArrayType and OutputIncompleteArrayType methods to generate the ArrayType element. Report the min="", max="", and type="" of the array elements and queue the type.
-rw-r--r--src/Output.cxx26
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/expect/gccxml.ArrayType-incomplete-xml.txt8
-rw-r--r--test/expect/gccxml.ArrayType-xml.txt8
-rw-r--r--test/input/ArrayType-incomplete.cxx1
-rw-r--r--test/input/ArrayType.cxx1
6 files changed, 46 insertions, 0 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index e47a445..f81c63e 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -217,6 +217,10 @@ class ASTVisitor: public ASTVisitorBase
// Type node output methods.
void OutputBuiltinType(clang::BuiltinType const* t, DumpNode const* dn);
+ void OutputConstantArrayType(clang::ConstantArrayType const* t,
+ DumpNode const* dn);
+ void OutputIncompleteArrayType(clang::IncompleteArrayType const* t,
+ DumpNode const* dn);
void OutputLValueReferenceType(clang::LValueReferenceType const* t,
DumpNode const* dn);
void OutputPointerType(clang::PointerType const* t, DumpNode const* dn);
@@ -681,6 +685,28 @@ void ASTVisitor::OutputBuiltinType(clang::BuiltinType const* t,
}
//----------------------------------------------------------------------------
+void ASTVisitor::OutputConstantArrayType(clang::ConstantArrayType const* t,
+ DumpNode const* dn)
+{
+ this->OS << " <ArrayType";
+ this->PrintIdAttribute(dn);
+ this->OS << " min=\"0\" max=\"" << (t->getSize()-1) << "\"";
+ this->PrintTypeAttribute(t->getElementType(), dn->Complete);
+ this->OS << "/>\n";
+}
+
+//----------------------------------------------------------------------------
+void ASTVisitor::OutputIncompleteArrayType(clang::IncompleteArrayType const* t,
+ DumpNode const* dn)
+{
+ this->OS << " <ArrayType";
+ this->PrintIdAttribute(dn);
+ this->OS << " min=\"0\" max=\"\"";
+ this->PrintTypeAttribute(t->getElementType(), dn->Complete);
+ this->OS << "/>\n";
+}
+
+//----------------------------------------------------------------------------
void ASTVisitor::OutputLValueReferenceType(clang::LValueReferenceType const* t,
DumpNode const* dn)
{
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b47f528..2d5b0eb 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -51,6 +51,8 @@ castxml_test_cmd(gccxml-twice --castxml-gccxml --castxml-gccxml)
castxml_test_cmd(o-missing -o)
castxml_test_cmd(start-missing --castxml-start)
+castxml_test_gccxml(ArrayType)
+castxml_test_gccxml(ArrayType-incomplete)
castxml_test_gccxml(Class)
castxml_test_gccxml(Class-incomplete)
castxml_test_gccxml(CvQualifiedType)
diff --git a/test/expect/gccxml.ArrayType-incomplete-xml.txt b/test/expect/gccxml.ArrayType-incomplete-xml.txt
new file mode 100644
index 0000000..d0203e9
--- /dev/null
+++ b/test/expect/gccxml.ArrayType-incomplete-xml.txt
@@ -0,0 +1,8 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Typedef id="_1" name="start" type="_2" context="_3" location="f1:1" file="f1" line="1"/>
+ <ArrayType id="_2" min="0" max="" type="_4"/>
+ <FundamentalType id="_4" name="int"/>
+ <Namespace id="_3" name="::"/>
+ <File id="f1" name=".*/test/input/ArrayType-incomplete.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.ArrayType-xml.txt b/test/expect/gccxml.ArrayType-xml.txt
new file mode 100644
index 0000000..e48bd3d
--- /dev/null
+++ b/test/expect/gccxml.ArrayType-xml.txt
@@ -0,0 +1,8 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Typedef id="_1" name="start" type="_2" context="_3" location="f1:1" file="f1" line="1"/>
+ <ArrayType id="_2" min="0" max="1" type="_4"/>
+ <FundamentalType id="_4" name="int"/>
+ <Namespace id="_3" name="::"/>
+ <File id="f1" name=".*/test/input/ArrayType.cxx"/>
+</GCC_XML>$
diff --git a/test/input/ArrayType-incomplete.cxx b/test/input/ArrayType-incomplete.cxx
new file mode 100644
index 0000000..d64de3b
--- /dev/null
+++ b/test/input/ArrayType-incomplete.cxx
@@ -0,0 +1 @@
+typedef int start[];
diff --git a/test/input/ArrayType.cxx b/test/input/ArrayType.cxx
new file mode 100644
index 0000000..6044ebe
--- /dev/null
+++ b/test/input/ArrayType.cxx
@@ -0,0 +1 @@
+typedef int start[2];