summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-08-18 17:52:39 (GMT)
committerBrad King <brad.king@kitware.com>2015-08-18 19:12:18 (GMT)
commite73fba54fd7347b94a6951903eac8479495654f2 (patch)
treefe8e1ebc6975072b83e0689414ebc40cd1998c67 /test
parentc7c836f667300470f12820fe9128e10afbbe2267 (diff)
downloadCastXML-e73fba54fd7347b94a6951903eac8479495654f2.zip
CastXML-e73fba54fd7347b94a6951903eac8479495654f2.tar.gz
CastXML-e73fba54fd7347b94a6951903eac8479495654f2.tar.bz2
Output: Add annotate() to function declaration attributes=""
While CastXML cannot support the `gccxml()` attribute because Clang does not define it, we can support the `annotate()` attribute that Clang provides for arbitrary string annotations. This should fill the same use case as the `gccxml()` attribute did for clients. GitHub-Issue: 25
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt8
-rw-r--r--test/expect/gccxml.any.Constructor-annotate.xml.txt17
-rw-r--r--test/expect/gccxml.any.Converter-annotate.xml.txt19
-rw-r--r--test/expect/gccxml.any.Destructor-annotate.xml.txt17
-rw-r--r--test/expect/gccxml.any.Function-annotate.xml.txt10
-rw-r--r--test/expect/gccxml.any.Function-calling-convention-ms-annotate.xml.txt26
-rw-r--r--test/expect/gccxml.any.Method-annotate.xml.txt21
-rw-r--r--test/expect/gccxml.any.OperatorFunction-annotate.xml.txt13
-rw-r--r--test/expect/gccxml.any.OperatorMethod-annotate.xml.txt21
-rw-r--r--test/input/Constructor-annotate.cxx3
-rw-r--r--test/input/Converter-annotate.cxx3
-rw-r--r--test/input/Destructor-annotate.cxx3
-rw-r--r--test/input/Function-annotate.cxx1
-rw-r--r--test/input/Function-calling-convention-ms-annotate.cxx4
-rw-r--r--test/input/Method-annotate.cxx3
-rw-r--r--test/input/OperatorFunction-annotate.cxx4
-rw-r--r--test/input/OperatorMethod-annotate.cxx3
-rw-r--r--test/run.cmake1
18 files changed, 177 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 23e956d..4c21e8a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -192,13 +192,17 @@ castxml_test_gccxml(Class-template-member-Typedef)
castxml_test_gccxml(Class-template-member-Typedef-const)
castxml_test_gccxml(Class-template-member-template)
castxml_test_gccxml(Constructor)
+castxml_test_gccxml(Constructor-annotate)
castxml_test_gccxml(Converter)
+castxml_test_gccxml(Converter-annotate)
castxml_test_gccxml(CvQualifiedType)
castxml_test_gccxml(Destructor)
+castxml_test_gccxml(Destructor-annotate)
castxml_test_gccxml(Enumeration)
castxml_test_gccxml(Enumeration-anonymous)
castxml_test_gccxml(Field)
castxml_test_gccxml(Function)
+castxml_test_gccxml(Function-annotate)
castxml_test_gccxml(Function-Argument-decay)
castxml_test_gccxml(Function-Argument-default)
castxml_test_gccxml(Function-rvalue-reference)
@@ -210,6 +214,7 @@ castxml_test_gccxml(FunctionType-variadic)
castxml_test_gccxml(FundamentalType)
castxml_test_gccxml(FundamentalTypes)
castxml_test_gccxml(Method)
+castxml_test_gccxml(Method-annotate)
castxml_test_gccxml(Method-rvalue-reference)
castxml_test_gccxml(MethodType)
castxml_test_gccxml(MethodType-cv)
@@ -230,7 +235,9 @@ castxml_test_gccxml(Namespace-repeat-start)
castxml_test_gccxml(OffsetType)
castxml_test_gccxml(OffsetType-cv)
castxml_test_gccxml(OperatorFunction)
+castxml_test_gccxml(OperatorFunction-annotate)
castxml_test_gccxml(OperatorMethod)
+castxml_test_gccxml(OperatorMethod-annotate)
castxml_test_gccxml(PointerType)
castxml_test_gccxml(ReferenceType)
castxml_test_gccxml(RValueReferenceType)
@@ -263,6 +270,7 @@ castxml_test_gccxml(using-directive-start)
if(";${LLVM_TARGETS_TO_BUILD};" MATCHES ";X86;")
set(castxml_test_gccxml_extra_arguments -target i386-pc-windows-msvc)
castxml_test_gccxml(Function-calling-convention-ms)
+ castxml_test_gccxml(Function-calling-convention-ms-annotate)
castxml_test_gccxml(implicit-decl-ms)
castxml_test_gccxml(inline-asm-ms)
unset(castxml_test_gccxml_extra_arguments)
diff --git a/test/expect/gccxml.any.Constructor-annotate.xml.txt b/test/expect/gccxml.any.Constructor-annotate.xml.txt
new file mode 100644
index 0000000..90c7f02
--- /dev/null
+++ b/test/expect/gccxml.any.Constructor-annotate.xml.txt
@@ -0,0 +1,17 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6" size="[0-9]+" align="[0-9]+"/>
+ <Constructor id="_3" name="start" context="_1" access="private" location="f1:2" file="f1" line="2" attributes="annotate\(an annotation\)"/>
+ <Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
+ <Argument type="_7" location="f1:1" file="f1" line="1"/>
+ </Constructor>
+ <OperatorMethod id="_5" name="=" returns="_8" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")? mangled="[^"]+">
+ <Argument type="_7" location="f1:1" file="f1" line="1"/>
+ </OperatorMethod>
+ <Destructor id="_6" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <ReferenceType id="_7" type="_1c"/>
+ <CvQualifiedType id="_1c" type="_1" const="1"/>
+ <ReferenceType id="_8" type="_1"/>
+ <Namespace id="_2" name="::"/>
+ <File id="f1" name=".*/test/input/Constructor-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.Converter-annotate.xml.txt b/test/expect/gccxml.any.Converter-annotate.xml.txt
new file mode 100644
index 0000000..0642674
--- /dev/null
+++ b/test/expect/gccxml.any.Converter-annotate.xml.txt
@@ -0,0 +1,19 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6 _7" size="[0-9]+" align="[0-9]+"/>
+ <Converter id="_3" returns="_8" context="_1" access="private" location="f1:2" file="f1" line="2" mangled="[^"]+" attributes="annotate\(an annotation\)"/>
+ <Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
+ <Argument type="_9" location="f1:1" file="f1" line="1"/>
+ </Constructor>
+ <OperatorMethod id="_6" name="=" returns="_10" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")? mangled="[^"]+">
+ <Argument type="_9" location="f1:1" file="f1" line="1"/>
+ </OperatorMethod>
+ <Destructor id="_7" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <FundamentalType id="_8" name="int" size="[0-9]+" align="[0-9]+"/>
+ <ReferenceType id="_9" type="_1c"/>
+ <CvQualifiedType id="_1c" type="_1" const="1"/>
+ <ReferenceType id="_10" type="_1"/>
+ <Namespace id="_2" name="::"/>
+ <File id="f1" name=".*/test/input/Converter-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.Destructor-annotate.xml.txt b/test/expect/gccxml.any.Destructor-annotate.xml.txt
new file mode 100644
index 0000000..0660f79
--- /dev/null
+++ b/test/expect/gccxml.any.Destructor-annotate.xml.txt
@@ -0,0 +1,17 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6" size="[0-9]+" align="[0-9]+"/>
+ <Destructor id="_3" name="start" context="_1" access="private" location="f1:2" file="f1" line="2" attributes="annotate\(an annotation\)"/>
+ <Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
+ <Argument type="_7" location="f1:1" file="f1" line="1"/>
+ </Constructor>
+ <OperatorMethod id="_6" name="=" returns="_8" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")? mangled="[^"]+">
+ <Argument type="_7" location="f1:1" file="f1" line="1"/>
+ </OperatorMethod>
+ <ReferenceType id="_7" type="_1c"/>
+ <CvQualifiedType id="_1c" type="_1" const="1"/>
+ <ReferenceType id="_8" type="_1"/>
+ <Namespace id="_2" name="::"/>
+ <File id="f1" name=".*/test/input/Destructor-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.Function-annotate.xml.txt b/test/expect/gccxml.any.Function-annotate.xml.txt
new file mode 100644
index 0000000..3f98887
--- /dev/null
+++ b/test/expect/gccxml.any.Function-annotate.xml.txt
@@ -0,0 +1,10 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Function id="_1" name="start" returns="_2" context="_3" location="f1:1" file="f1" line="1" mangled="[^"]+" attributes="annotate\(an annotation\)">
+ <Argument type="_4" location="f1:1" file="f1" line="1"/>
+ </Function>
+ <FundamentalType id="_2" name="void" size="[0-9]+" align="[0-9]+"/>
+ <FundamentalType id="_4" name="int" size="[0-9]+" align="[0-9]+"/>
+ <Namespace id="_3" name="::"/>
+ <File id="f1" name=".*/test/input/Function-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.Function-calling-convention-ms-annotate.xml.txt b/test/expect/gccxml.any.Function-calling-convention-ms-annotate.xml.txt
new file mode 100644
index 0000000..ba7fb08
--- /dev/null
+++ b/test/expect/gccxml.any.Function-calling-convention-ms-annotate.xml.txt
@@ -0,0 +1,26 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Function id="_1" name="start" returns="_5" context="_6" location="f1:1" file="f1" line="1" mangled="[^"]+" attributes="annotate\(an annotation\)">
+ <Argument type="_7" location="f1:1" file="f1" line="1"/>
+ </Function>
+ <Function id="_2" name="start" returns="_5" context="_6" location="f1:2" file="f1" line="2" mangled="[^"]+" attributes="__stdcall__ annotate\(an annotation\)">
+ <Argument type="_8" location="f1:2" file="f1" line="2"/>
+ </Function>
+ <Function id="_3" name="start" returns="_5" context="_6" location="f1:3" file="f1" line="3" mangled="[^"]+" attributes="__fastcall__ annotate\(an annotation\)">
+ <Argument type="_9" location="f1:3" file="f1" line="3"/>
+ </Function>
+ <Function id="_4" name="start" returns="_5" context="_6" location="f1:4" file="f1" line="4" mangled="[^"]+" attributes="__thiscall__ annotate\(an annotation\)">
+ <Argument type="_10" location="f1:4" file="f1" line="4"/>
+ </Function>
+ <FundamentalType id="_5" name="void" size="[0-9]+" align="[0-9]+"/>
+ <PointerType id="_7" type="_11"/>
+ <PointerType id="_8" type="_12"/>
+ <PointerType id="_9" type="_13"/>
+ <PointerType id="_10" type="_14"/>
+ <Namespace id="_6" name="::"/>
+ <FunctionType id="_11" returns="_5"/>
+ <FunctionType id="_12" returns="_5" attributes="__stdcall__"/>
+ <FunctionType id="_13" returns="_5" attributes="__fastcall__"/>
+ <FunctionType id="_14" returns="_5" attributes="__thiscall__"/>
+ <File id="f1" name=".*/test/input/Function-calling-convention-ms-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.Method-annotate.xml.txt b/test/expect/gccxml.any.Method-annotate.xml.txt
new file mode 100644
index 0000000..3e4f2f3
--- /dev/null
+++ b/test/expect/gccxml.any.Method-annotate.xml.txt
@@ -0,0 +1,21 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6 _7" size="[0-9]+" align="[0-9]+"/>
+ <Method id="_3" name="method" returns="_8" context="_1" access="private" location="f1:2" file="f1" line="2" mangled="[^"]+" attributes="annotate\(an annotation\)">
+ <Argument type="_8" location="f1:2" file="f1" line="2"/>
+ </Method>
+ <Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
+ <Argument type="_9" location="f1:1" file="f1" line="1"/>
+ </Constructor>
+ <OperatorMethod id="_6" name="=" returns="_10" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")? mangled="[^"]+">
+ <Argument type="_9" location="f1:1" file="f1" line="1"/>
+ </OperatorMethod>
+ <Destructor id="_7" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <FundamentalType id="_8" name="int" size="[0-9]+" align="[0-9]+"/>
+ <ReferenceType id="_9" type="_1c"/>
+ <CvQualifiedType id="_1c" type="_1" const="1"/>
+ <ReferenceType id="_10" type="_1"/>
+ <Namespace id="_2" name="::"/>
+ <File id="f1" name=".*/test/input/Method-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.OperatorFunction-annotate.xml.txt b/test/expect/gccxml.any.OperatorFunction-annotate.xml.txt
new file mode 100644
index 0000000..8393bd2
--- /dev/null
+++ b/test/expect/gccxml.any.OperatorFunction-annotate.xml.txt
@@ -0,0 +1,13 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Namespace id="_1" name="start" context="_2" members="_3"/>
+ <OperatorFunction id="_3" name="&lt;&lt;" returns="_4" context="_1" location="f1:3" file="f1" line="3" mangled="[^"]+" attributes="annotate\(an annotation\)">
+ <Argument type="_4" location="f1:3" file="f1" line="3"/>
+ <Argument type="_5" location="f1:3" file="f1" line="3"/>
+ </OperatorFunction>
+ <ReferenceType id="_4" type="_6"/>
+ <FundamentalType id="_5" name="int" size="[0-9]+" align="[0-9]+"/>
+ <Namespace id="_2" name="::"/>
+ <Class id="_6" name="A" context="_2" location="f1:1" file="f1" line="1" incomplete="1"/>
+ <File id="f1" name=".*/test/input/OperatorFunction-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.OperatorMethod-annotate.xml.txt b/test/expect/gccxml.any.OperatorMethod-annotate.xml.txt
new file mode 100644
index 0000000..692cd5e
--- /dev/null
+++ b/test/expect/gccxml.any.OperatorMethod-annotate.xml.txt
@@ -0,0 +1,21 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6 _7" size="[0-9]+" align="[0-9]+"/>
+ <OperatorMethod id="_3" name="&lt;&lt;" returns="_8" context="_1" access="private" location="f1:2" file="f1" line="2" mangled="[^"]+" attributes="annotate\(an annotation\)">
+ <Argument type="_9" location="f1:2" file="f1" line="2"/>
+ </OperatorMethod>
+ <Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
+ <Argument type="_10" location="f1:1" file="f1" line="1"/>
+ </Constructor>
+ <OperatorMethod id="_6" name="=" returns="_8" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")? mangled="[^"]+">
+ <Argument type="_10" location="f1:1" file="f1" line="1"/>
+ </OperatorMethod>
+ <Destructor id="_7" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
+ <ReferenceType id="_8" type="_1"/>
+ <FundamentalType id="_9" name="int" size="[0-9]+" align="[0-9]+"/>
+ <ReferenceType id="_10" type="_1c"/>
+ <CvQualifiedType id="_1c" type="_1" const="1"/>
+ <Namespace id="_2" name="::"/>
+ <File id="f1" name=".*/test/input/OperatorMethod-annotate.cxx"/>
+</GCC_XML>$
diff --git a/test/input/Constructor-annotate.cxx b/test/input/Constructor-annotate.cxx
new file mode 100644
index 0000000..94cf13e
--- /dev/null
+++ b/test/input/Constructor-annotate.cxx
@@ -0,0 +1,3 @@
+class start {
+ __attribute__ ((annotate ("an annotation"))) start();
+};
diff --git a/test/input/Converter-annotate.cxx b/test/input/Converter-annotate.cxx
new file mode 100644
index 0000000..2e4a915
--- /dev/null
+++ b/test/input/Converter-annotate.cxx
@@ -0,0 +1,3 @@
+class start {
+ __attribute__ ((annotate ("an annotation"))) operator int();
+};
diff --git a/test/input/Destructor-annotate.cxx b/test/input/Destructor-annotate.cxx
new file mode 100644
index 0000000..f2c59f1
--- /dev/null
+++ b/test/input/Destructor-annotate.cxx
@@ -0,0 +1,3 @@
+class start {
+ __attribute__ ((annotate ("an annotation"))) ~start();
+};
diff --git a/test/input/Function-annotate.cxx b/test/input/Function-annotate.cxx
new file mode 100644
index 0000000..d7aaf79
--- /dev/null
+++ b/test/input/Function-annotate.cxx
@@ -0,0 +1 @@
+__attribute__ ((annotate ("an annotation"))) void start(int);
diff --git a/test/input/Function-calling-convention-ms-annotate.cxx b/test/input/Function-calling-convention-ms-annotate.cxx
new file mode 100644
index 0000000..4803dd8
--- /dev/null
+++ b/test/input/Function-calling-convention-ms-annotate.cxx
@@ -0,0 +1,4 @@
+__attribute__ ((annotate ("an annotation"))) void __cdecl start(void (__cdecl *)());
+__attribute__ ((annotate ("an annotation"))) void __stdcall start(void (__stdcall *)());
+__attribute__ ((annotate ("an annotation"))) void __fastcall start(void (__fastcall *)());
+__attribute__ ((annotate ("an annotation"))) void __thiscall start(void (__thiscall *)());
diff --git a/test/input/Method-annotate.cxx b/test/input/Method-annotate.cxx
new file mode 100644
index 0000000..cbd02cf
--- /dev/null
+++ b/test/input/Method-annotate.cxx
@@ -0,0 +1,3 @@
+class start {
+ __attribute__ ((annotate ("an annotation"))) int method(int);
+};
diff --git a/test/input/OperatorFunction-annotate.cxx b/test/input/OperatorFunction-annotate.cxx
new file mode 100644
index 0000000..bbb3bf9
--- /dev/null
+++ b/test/input/OperatorFunction-annotate.cxx
@@ -0,0 +1,4 @@
+class A;
+namespace start {
+ __attribute__ ((annotate ("an annotation"))) A& operator<<(A&, int);
+}
diff --git a/test/input/OperatorMethod-annotate.cxx b/test/input/OperatorMethod-annotate.cxx
new file mode 100644
index 0000000..3384ece
--- /dev/null
+++ b/test/input/OperatorMethod-annotate.cxx
@@ -0,0 +1,3 @@
+class start {
+ __attribute__ ((annotate ("an annotation"))) start& operator<<(int);
+};
diff --git a/test/run.cmake b/test/run.cmake
index 1b973b3..e9911a6 100644
--- a/test/run.cmake
+++ b/test/run.cmake
@@ -84,6 +84,7 @@ if(msg)
set(update_xml "${actual_xml}")
string(REGEX REPLACE "^<\\?xml version=\"1.0\"\\?>" "^<\\\\?xml version=\"1.0\"\\\\?>" update_xml "${update_xml}")
string(REGEX REPLACE "<GCC_XML[^>]*>" "<GCC_XML[^>]*>" update_xml "${update_xml}")
+ string(REGEX REPLACE "([()])" "\\\\\\1" update_xml "${update_xml}")
string(REGEX REPLACE "mangled=\"[^\"]*\"" "mangled=\"[^\"]+\"" update_xml "${update_xml}")
string(REGEX REPLACE "artificial=\"1\"( throw=\"\")?" "artificial=\"1\"( throw=\"\")?" update_xml "${update_xml}")
string(REGEX REPLACE "size=\"[0-9]+\" align=\"[0-9]+\"" "size=\"[0-9]+\" align=\"[0-9]+\"" update_xml "${update_xml}")