diff options
author | Brad King <brad.king@kitware.com> | 2014-03-21 17:23:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-24 18:19:04 (GMT) |
commit | beea56e5aedd3b41a674d6ea548d34d428fa2678 (patch) | |
tree | 2d54d4c89f40b63a62fbd738b7a3b969efb1771c | |
parent | 5ba34a458bb4ba183f2081956bc27aa0e520d781 (diff) | |
download | CastXML-beea56e5aedd3b41a674d6ea548d34d428fa2678.zip CastXML-beea56e5aedd3b41a674d6ea548d34d428fa2678.tar.gz CastXML-beea56e5aedd3b41a674d6ea548d34d428fa2678.tar.bz2 |
Output: Drop from Namespace members="" non-inline class members
Clang presents non-inline class members in the list of declarations in
a namespace. Teach PrintMembersAttribute to skip declarations whose
actual context is not the context that listed them.
-rw-r--r-- | src/Output.cxx | 5 | ||||
-rw-r--r-- | test/CMakeLists.txt | 3 | ||||
-rw-r--r-- | test/expect/gccxml.Namespace-Class-members-xml.txt | 20 | ||||
-rw-r--r-- | test/expect/gccxml.Namespace-Class-template-members-xml.txt | 5 | ||||
-rw-r--r-- | test/expect/gccxml.Namespace-Function-template-members-xml.txt | 5 | ||||
-rw-r--r-- | test/input/Namespace-Class-members.cxx | 6 | ||||
-rw-r--r-- | test/input/Namespace-Class-template-members.cxx | 6 | ||||
-rw-r--r-- | test/input/Namespace-Function-template-members.cxx | 3 |
8 files changed, 53 insertions, 0 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index 08519cc..ebbe175 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -828,6 +828,11 @@ void ASTVisitor::PrintMembersAttribute(clang::DeclContext const* dc) e = dc->decls_end(); i != e; ++i) { clang::Decl const* d = *i; + // Skip declarations that are not really members of this context. + if(d->getDeclContext() != dc) { + continue; + } + // Ignore certain members. switch (d->getKind()) { case clang::Decl::CXXRecord: { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c73186e..b406172 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -118,6 +118,9 @@ castxml_test_gccxml(Method) castxml_test_gccxml(MethodType) castxml_test_gccxml(MethodType-cv) castxml_test_gccxml(Namespace) +castxml_test_gccxml(Namespace-Class-members) +castxml_test_gccxml(Namespace-Class-template-members) +castxml_test_gccxml(Namespace-Function-template-members) castxml_test_gccxml(OffsetType) castxml_test_gccxml(OffsetType-cv) castxml_test_gccxml(OperatorFunction) diff --git a/test/expect/gccxml.Namespace-Class-members-xml.txt b/test/expect/gccxml.Namespace-Class-members-xml.txt new file mode 100644 index 0000000..44146be --- /dev/null +++ b/test/expect/gccxml.Namespace-Class-members-xml.txt @@ -0,0 +1,20 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Namespace id="_1" name="start" context="_2" members="_3"/> + <Class id="_3" name="A" context="_1" location="f1:2" file="f1" line="2" members="_4 _5 _6 _7 _8"/> + <Variable id="_4" name="data" type="_9" context="_3" access="private" location="f1:3" file="f1" line="3" static="1"/> + <Constructor id="_5" name="A" context="_3" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"/> + <Constructor id="_6" name="A" context="_3" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"> + <Argument type="_10" location="f1:2" file="f1" line="2"/> + </Constructor> + <OperatorMethod id="_7" name="=" returns="_11" context="_3" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"> + <Argument type="_10" location="f1:2" file="f1" line="2"/> + </OperatorMethod> + <Destructor id="_8" name="A" context="_3" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"/> + <FundamentalType id="_9" name="int"/> + <ReferenceType id="_10" type="_3c"/> + <ReferenceType id="_11" type="_3"/> + <Namespace id="_2" name="::"/> + <CvQualifiedType id="_3c" type="_3" const="1"/> + <File id="f1" name=".*/test/input/Namespace-Class-members.cxx"/> +</GCC_XML>$ diff --git a/test/expect/gccxml.Namespace-Class-template-members-xml.txt b/test/expect/gccxml.Namespace-Class-template-members-xml.txt new file mode 100644 index 0000000..763161e --- /dev/null +++ b/test/expect/gccxml.Namespace-Class-template-members-xml.txt @@ -0,0 +1,5 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Namespace id="_1" name="start" context="_2"/> + <Namespace id="_2" name="::"/> +</GCC_XML>$ diff --git a/test/expect/gccxml.Namespace-Function-template-members-xml.txt b/test/expect/gccxml.Namespace-Function-template-members-xml.txt new file mode 100644 index 0000000..763161e --- /dev/null +++ b/test/expect/gccxml.Namespace-Function-template-members-xml.txt @@ -0,0 +1,5 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Namespace id="_1" name="start" context="_2"/> + <Namespace id="_2" name="::"/> +</GCC_XML>$ diff --git a/test/input/Namespace-Class-members.cxx b/test/input/Namespace-Class-members.cxx new file mode 100644 index 0000000..0b196ea --- /dev/null +++ b/test/input/Namespace-Class-members.cxx @@ -0,0 +1,6 @@ +namespace start { + class A { + static int data; + }; + int A::data; +} diff --git a/test/input/Namespace-Class-template-members.cxx b/test/input/Namespace-Class-template-members.cxx new file mode 100644 index 0000000..5367a14 --- /dev/null +++ b/test/input/Namespace-Class-template-members.cxx @@ -0,0 +1,6 @@ +namespace start { + template <typename T> class A { + static int data; + }; + template <typename T> int A<T>::data; +} diff --git a/test/input/Namespace-Function-template-members.cxx b/test/input/Namespace-Function-template-members.cxx new file mode 100644 index 0000000..925281f --- /dev/null +++ b/test/input/Namespace-Function-template-members.cxx @@ -0,0 +1,3 @@ +namespace start { + template <typename T> T function(T); +} |