From 5db858953001c534341562cfaeba39782abc5ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 29 Dec 2017 14:18:45 +0100 Subject: XML output: avoid warnings with scoped enum values in anonymous namespaces. When a C++11 `enum class` was present in an anonymous namespace (usually in *.cpp files), the XML output was emitting warnings similar to the following: Internal inconsistency: member False does not belong to any container! And the XML output was rendering bogus IDs for enum values starting with `dummy_`, such as: dummy_1a96ab6574751fdf6a53ceec8a3896c45daf8320b26d30ab433c5a54546d21f414c The fix is to call memberOutputFileBase() on the enumeration itself and not on the enum value, that way it provides correct file base that corresponds to file base of the enumeration. There's also a new test that checks this. Note: this assumes that enum values belong to the same compound as enums themselves. In my experience that was always the case and there's no broken test after this change, so I hope I didn't break anything. --- src/xmlgen.cpp | 6 ++-- testing/071/namespace_a_namespace_1_1_0D0.xml | 45 +++++++++++++++++++++++++++ testing/071_enum_in_anon_ns.cpp | 12 +++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 testing/071/namespace_a_namespace_1_1_0D0.xml create mode 100644 testing/071_enum_in_anon_ns.cpp diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 2222e46..697a4d8 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -954,11 +954,11 @@ static void generateXMLForMember(MemberDef *md,FTextStream &ti,FTextStream &t,De MemberDef *emd; for (emli.toFirst();(emd=emli.current());++emli) { - ti << " anchor() << "\" kind=\"enumvalue\">" + ti << " anchor() << "\" kind=\"enumvalue\">" << convertToXML(emd->name()) << "" << endl; - t << " anchor() << "\" prot=\""; switch (emd->protection()) { diff --git a/testing/071/namespace_a_namespace_1_1_0D0.xml b/testing/071/namespace_a_namespace_1_1_0D0.xml new file mode 100644 index 0000000..76483ca --- /dev/null +++ b/testing/071/namespace_a_namespace_1_1_0D0.xml @@ -0,0 +1,45 @@ + + + + ANamespace::@0 + + + + Boolean + + False + + + + + + + True + + + + + + + FileNotFound + + + + + + + + + + + + + + + + + + + + + diff --git a/testing/071_enum_in_anon_ns.cpp b/testing/071_enum_in_anon_ns.cpp new file mode 100644 index 0000000..a5b9ac8 --- /dev/null +++ b/testing/071_enum_in_anon_ns.cpp @@ -0,0 +1,12 @@ +// objective: test that enum values in anonymous namespaces produce no warning +// check: namespace_a_namespace_1_1_0D0.xml + +namespace ANamespace { namespace { + +enum class Boolean { + False, + True, + FileNotFound +}; + +}} -- cgit v0.12