diff options
-rw-r--r-- | src/Output.cxx | 8 | ||||
-rw-r--r-- | test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/expect/gccxml.Enumeration-anonymous-xml.txt | 10 | ||||
-rw-r--r-- | test/expect/gccxml.Typedef-to-Enumeration-anonymous-xml.txt | 7 | ||||
-rw-r--r-- | test/input/Enumeration-anonymous.cxx | 6 | ||||
-rw-r--r-- | test/input/Typedef-to-Enumeration-anonymous.cxx | 2 |
6 files changed, 34 insertions, 1 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index b988560..e3a8ffb 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -1174,7 +1174,13 @@ void ASTVisitor::OutputEnumDecl(clang::EnumDecl const* d, DumpNode const* dn) { this->OS << " <Enumeration"; this->PrintIdAttribute(dn); - this->PrintNameAttribute(d->getName().str()); + std::string name = d->getName().str(); + if(name.empty()) { + if(clang::TypedefNameDecl const* td = d->getTypedefNameForAnonDecl()) { + name = td->getName().str(); + } + } + this->PrintNameAttribute(name); this->PrintContextAttribute(d); this->PrintLocationAttribute(d); clang::EnumDecl::enumerator_iterator enum_begin = d->enumerator_begin(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ec842d2..6fc5cf8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -95,6 +95,7 @@ castxml_test_gccxml(Class-template-bases) castxml_test_gccxml(Class-template-member-template) castxml_test_gccxml(CvQualifiedType) castxml_test_gccxml(Enumeration) +castxml_test_gccxml(Enumeration-anonymous) castxml_test_gccxml(Field) castxml_test_gccxml(Function) castxml_test_gccxml(Function-Argument-default) @@ -118,6 +119,7 @@ castxml_test_gccxml(ReferenceType) castxml_test_gccxml(Typedef-paren) castxml_test_gccxml(Typedef-to-Class-template) castxml_test_gccxml(Typedef-to-Enumeration) +castxml_test_gccxml(Typedef-to-Enumeration-anonymous) castxml_test_gccxml(Variable) castxml_test_gccxml(Variable-in-Class) castxml_test_gccxml(Variable-init) diff --git a/test/expect/gccxml.Enumeration-anonymous-xml.txt b/test/expect/gccxml.Enumeration-anonymous-xml.txt new file mode 100644 index 0000000..385975b --- /dev/null +++ b/test/expect/gccxml.Enumeration-anonymous-xml.txt @@ -0,0 +1,10 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Namespace id="_1" name="start" context="_2" members="_3"/> + <Enumeration id="_3" name="" context="_1" location="f1:2" file="f1" line="2"> + <EnumValue name="ev0" init="0"/> + <EnumValue name="ev1" init="1"/> + </Enumeration> + <Namespace id="_2" name="::"/> + <File id="f1" name=".*/test/input/Enumeration-anonymous.cxx"/> +</GCC_XML>$ diff --git a/test/expect/gccxml.Typedef-to-Enumeration-anonymous-xml.txt b/test/expect/gccxml.Typedef-to-Enumeration-anonymous-xml.txt new file mode 100644 index 0000000..bb21d49 --- /dev/null +++ b/test/expect/gccxml.Typedef-to-Enumeration-anonymous-xml.txt @@ -0,0 +1,7 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Typedef id="_1" name="start" type="_2" context="_3" location="f1:2" file="f1" line="2"/> + <Enumeration id="_2" name="start" context="_3" location="f1:1" file="f1" line="1"/> + <Namespace id="_3" name="::"/> + <File id="f1" name=".*/test/input/Typedef-to-Enumeration-anonymous.cxx"/> +</GCC_XML>$ diff --git a/test/input/Enumeration-anonymous.cxx b/test/input/Enumeration-anonymous.cxx new file mode 100644 index 0000000..f1325d1 --- /dev/null +++ b/test/input/Enumeration-anonymous.cxx @@ -0,0 +1,6 @@ +namespace start { + enum { + ev0, + ev1 + }; +} diff --git a/test/input/Typedef-to-Enumeration-anonymous.cxx b/test/input/Typedef-to-Enumeration-anonymous.cxx new file mode 100644 index 0000000..cf5f26f --- /dev/null +++ b/test/input/Typedef-to-Enumeration-anonymous.cxx @@ -0,0 +1,2 @@ +typedef enum { +} start; |