Repository: CastXML/CastXML (language: python)

Issue:
Output: Add ElaboratedType elements with distinguishing attributes
Clang produces an ElaboratedType for two forms of type name elaboration:

* A keyword, e.g. `struct S`.
* A name qualifier, e.g. `ns::S`.

Since #81 we generate explicit ElaboratedType  elements for keyword
elaboration, but not for name qualifiers.  Add a `keyword=` attribute.

In cases where multiple PointerType or ReferenceType nodes reference
the same type through different name qualifier elaborations, removing
the ElaboratedType from the graph causes the referencing nodes to
appear duplicated (see the `Elaborated-ns` test cases, for example).

Add explicit ElaboratedType elements with a `qualifer=` attribute for
name qualifier elaboration.  Increment the format *major* version number
to indicate the addition of an element, in places it did not previously
appear, that will require clients to be updated.



Discussion / hints:

Fix patch:
diff --git a/doc/manual/castxml.xsd b/doc/manual/castxml.xsd
index e2123c50..154bce73 100644
--- a/doc/manual/castxml.xsd
+++ b/doc/manual/castxml.xsd
@@ -358,6 +358,12 @@
         </xs:complexType>
       </xs:element>
 
+      <xs:element name="AutoType">
+        <xs:complexType>
+          <xs:attribute name="id" type="xs:ID" />
+        </xs:complexType>
+      </xs:element>
+
       <xs:element name="PointerType">
         <xs:complexType>
           <xs:attribute name="id" type="xs:ID" />
diff --git a/src/Output.cxx b/src/Output.cxx
index 5387eae1..3b05747b 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -573,6 +573,7 @@ class ASTVisitor : public ASTVisitorBase
 
   // Type node output methods.
   void OutputAtomicType(clang::AtomicType const* t, DumpNode const* dn);
+  void OutputAutoType(clang::AutoType const* t, DumpNode const* dn);
   void OutputBuiltinType(clang::BuiltinType const* t, DumpNode const* dn);
   void OutputConstantArrayType(clang::ConstantArrayType const* t,
                                DumpNode const* dn);
@@ -2293,6 +2294,17 @@ void ASTVisitor::OutputAtomicType(clang::AtomicType const* t,
   this->OS << "/>\n";
 }
 
+void ASTVisitor::OutputAutoType(clang::AutoType const* t, DumpNode const* dn)
+{
+  if (this->Opts.GccXml) {
+    this->OutputUnimplementedType(t, dn);
+    return;
+  }
+  this->OS << "  <AutoType";
+  this->PrintIdAttribute(dn);
+  this->OS << "/>\n";
+}
+
 void ASTVisitor::OutputBuiltinType(clang::BuiltinType const* t,
                                    DumpNode const* dn)
 {


Test patch:
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index fd91e471..d377baf0 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -504,6 +504,7 @@ castxml_test_output_11(Field-init)
 castxml_test_output(Function)
 castxml_test_output_c(Function)
 castxml_test_output_14(Function-auto)
+castxml_test_output_14(Function-auto-undeduced)
 castxml_test_output(Function-annotate)
 castxml_test_output(Function-deprecated)
 castxml_test_output(Function-extern-C)
diff --git a/test/expect/castxml1.any.Function-auto-undeduced.xml.txt b/test/expect/castxml1.any.Function-auto-undeduced.xml.txt
new file mode 100644
index 00000000..a1c7e354
--- /dev/null
+++ b/test/expect/castxml1.any.Function-auto-undeduced.xml.txt
@@ -0,0 +1,7 @@
+^<\?xml version="1.0"\?>
+<CastXML[^>]*>
+  <Function id="_1" name="start" returns="_2" context="_3" location="f1:1" file="f1" line="1" mangled="[^"]+"/>
+  <AutoType id="_2"/>
+  <Namespace id="_3" name="::"/>
+  <File id="f1" name=".*/test/input/Function-auto-undeduced.cxx"/>
+</CastXML>$
diff --git a/test/expect/gccxml.any.Function-auto-undeduced.xml.txt b/test/expect/gccxml.any.Function-auto-undeduced.xml.txt
new file mode 100644
index 00000000..eeaf8cd9
--- /dev/null
+++ b/test/expect/gccxml.any.Function-auto-undeduced.xml.txt
@@ -0,0 +1,7 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+  <Function id="_1" name="start" returns="_2" context="_3" location="f1:1" file="f1" line="1" mangled="[^"]+"/>
+  <Unimplemented id="_2" type_class="Auto"/>
+  <Namespace id="_3" name="::"/>
+  <File id="f1" name=".*/test/input/Function-auto-undeduced.cxx"/>
+</GCC_XML>$
diff --git a/test/input/Function-auto-undeduced.cxx b/test/input/Function-auto-undeduced.cxx
new file mode 100644
index 00000000..e5defec5
--- /dev/null
+++ b/test/input/Function-auto-undeduced.cxx
@@ -0,0 +1,1 @@
+auto start();