diff options
author | Brad King <brad.king@kitware.com> | 2015-12-11 21:29:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-12-14 16:44:22 (GMT) |
commit | f57109f31b94d0410e091a549a4aa0febc4140d6 (patch) | |
tree | e808c200077843a17e1873791cd3e9ac1f88beff /test | |
parent | d10ec2e51efcff37b655404dd755e34b5e122cb1 (diff) | |
download | CastXML-f57109f31b94d0410e091a549a4aa0febc4140d6.zip CastXML-f57109f31b94d0410e091a549a4aa0febc4140d6.tar.gz CastXML-f57109f31b94d0410e091a549a4aa0febc4140d6.tar.bz2 |
Output: Fix references to types whose declaration is invalid
We skip generating declarations that Clang has deemed invalid. Most
callers of AddDeclDumpNode can check the return value and handle the
lack of a valid decl. However, callers of AddDeclDumpNodeForType are
generating references to types and expect to get a valid element to
reference. We can get an invalid RecordDecl when it is a template
instantation that fails (but does not otherwise produce a compilation
error in Clang). References to types corresponding to the invalid
RecordDecl must remain valid, so generate a Class/Struct/Union element
anyway and simply leave out class members and bases.
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/expect/gccxml.any.invalid-decl-for-type.xml.txt | 32 | ||||
-rw-r--r-- | test/input/invalid-decl-for-type.cxx | 7 |
3 files changed, 40 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f83a182..97651f4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -315,6 +315,7 @@ castxml_test_gccxml(Namespace-nested-2) unset(castxml_test_gccxml_custom_start) unset(castxml_test_gccxml_custom_input) +castxml_test_gccxml(invalid-decl-for-type) castxml_test_gccxml(qualified-type-name) castxml_test_gccxml(using-declaration-class) castxml_test_gccxml(using-declaration-ns) diff --git a/test/expect/gccxml.any.invalid-decl-for-type.xml.txt b/test/expect/gccxml.any.invalid-decl-for-type.xml.txt new file mode 100644 index 0000000..4d3cbab --- /dev/null +++ b/test/expect/gccxml.any.invalid-decl-for-type.xml.txt @@ -0,0 +1,32 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Struct id="_1" name="start" context="_2" location="f1:4" file="f1" line="4" members="_3 _4 _5 _6 _7 _8" size="[0-9]+" align="[0-9]+"/> + <Field id="_3" name="b" type="_9" context="_1" access="public" location="f1:5" file="f1" line="5" offset="0"/> + <Typedef id="_4" name="type" type="_10" context="_1" access="public" location="f1:6" file="f1" line="6"/> + <Constructor id="_5" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"( throw="")?/> + <Constructor id="_6" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"( throw="")?> + <Argument type="_11" location="f1:4" file="f1" line="4"/> + </Constructor> + <OperatorMethod id="_7" name="=" returns="_12" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"( throw="")? mangled="[^"]+"> + <Argument type="_11" location="f1:4" file="f1" line="4"/> + </OperatorMethod> + <Destructor id="_8" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"( throw="")?/> + <Struct id="_9" name="B<Incomplete>" context="_2" location="f1:2" file="f1" line="2" members="_13 _14 _15 _16" size="[0-9]+" align="[0-9]+"/> + <Struct id="_10" name="A<Incomplete>" context="_2" location="f1:1" file="f1" line="1" size="[0-9]+" align="[0-9]+"/> + <ReferenceType id="_11" type="_1c"/> + <CvQualifiedType id="_1c" type="_1" const="1"/> + <ReferenceType id="_12" type="_1"/> + <Constructor id="_13" name="B" context="_9" access="public" location="f1:2" file="f1" line="2" inline="1"/> + <Constructor id="_14" name="B" context="_9" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"( throw="")?> + <Argument type="_17" location="f1:2" file="f1" line="2"/> + </Constructor> + <OperatorMethod id="_15" name="=" returns="_18" context="_9" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"( throw="")? mangled="[^"]+"> + <Argument type="_17" location="f1:2" file="f1" line="2"/> + </OperatorMethod> + <Destructor id="_16" name="B" context="_9" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"( throw="")?/> + <ReferenceType id="_17" type="_9c"/> + <CvQualifiedType id="_9c" type="_9" const="1"/> + <ReferenceType id="_18" type="_9"/> + <Namespace id="_2" name="::"/> + <File id="f1" name=".*/test/input/invalid-decl-for-type.cxx"/> +</GCC_XML>$ diff --git a/test/input/invalid-decl-for-type.cxx b/test/input/invalid-decl-for-type.cxx new file mode 100644 index 0000000..5c2225f --- /dev/null +++ b/test/input/invalid-decl-for-type.cxx @@ -0,0 +1,7 @@ +template<typename T> struct A { T x; }; +template<typename T> struct B { B() { A<T> a; } }; +struct Incomplete; +struct start { + B<Incomplete> b; + typedef A<Incomplete> type; +}; |