summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-11 15:09:21 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-11 15:54:32 (GMT)
commitaeb49468598774f683f1bc8bb50bd0e301a80fa3 (patch)
treecb52a73831ade1cef721e39722064fdb9e079a16
parent1a34898d200aff27a16c4efb67b783ccbcb44008 (diff)
downloadCastXML-aeb49468598774f683f1bc8bb50bd0e301a80fa3.zip
CastXML-aeb49468598774f683f1bc8bb50bd0e301a80fa3.tar.gz
CastXML-aeb49468598774f683f1bc8bb50bd0e301a80fa3.tar.bz2
Output: Drop functions with rvalue reference types from gccxml output
Improve support for -std=c++11 with --castxml-gccxml by dropping all functions and class methods whose signature contains a rvalue reference. This subsumes the previous check for implicit move constructors and implicit move assignment operators and extends it to explicitly written declarations too. Add test cases to verify that such declarations are excluded from the output.
-rw-r--r--src/Output.cxx23
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/expect/gccxml.any.Function-rvalue-reference.stdout.txt1
-rw-r--r--test/expect/gccxml.any.Function-rvalue-reference.xml.txt9
-rw-r--r--test/expect/gccxml.any.Method-rvalue-reference.stdout.txt1
-rw-r--r--test/expect/gccxml.any.Method-rvalue-reference.xml.txt18
-rw-r--r--test/expect/gccxml.c++11.Function-rvalue-reference.stderr.txt1
-rw-r--r--test/expect/gccxml.c++11.Method-rvalue-reference.stderr.txt1
-rw-r--r--test/expect/gccxml.c++98.Function-rvalue-reference.stderr.txt1
-rw-r--r--test/expect/gccxml.c++98.Method-rvalue-reference.stderr.txt1
-rw-r--r--test/input/Function-rvalue-reference.cxx3
-rw-r--r--test/input/Method-rvalue-reference.cxx9
12 files changed, 59 insertions, 11 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index ee7c830..91f9705 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -427,17 +427,18 @@ unsigned int ASTVisitor::AddDumpNode(clang::Decl const* d, bool complete) {
clang::dyn_cast<clang::FunctionDecl>(d)) {
if (fd->isDeleted()) {
return 0;
- } else if (clang::CXXMethodDecl const* md =
- clang::dyn_cast<clang::CXXMethodDecl>(fd)) {
- if (md->isImplicit()) {
- if (clang::CXXConstructorDecl const* cd =
- clang::dyn_cast<clang::CXXConstructorDecl>(md)) {
- if (cd->isMoveConstructor()) {
- return 0;
- }
- } else if (md->isMoveAssignmentOperator()) {
- return 0;
- }
+ }
+
+ clang::FunctionProtoType const* fpt =
+ fd->getType()->getAs<clang::FunctionProtoType>();
+ if (fpt->getReturnType()->isRValueReferenceType()) {
+ return 0;
+ }
+ for (clang::FunctionProtoType::param_type_iterator
+ i = fpt->param_type_begin(), e = fpt->param_type_end();
+ i != e; ++i) {
+ if((*i)->isRValueReferenceType()) {
+ return 0;
}
}
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index af36e84..a1f7c45 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -143,6 +143,7 @@ castxml_test_gccxml(Field)
castxml_test_gccxml(Function)
castxml_test_gccxml(Function-Argument-decay)
castxml_test_gccxml(Function-Argument-default)
+castxml_test_gccxml(Function-rvalue-reference)
castxml_test_gccxml(Function-template)
castxml_test_gccxml(Function-throw)
castxml_test_gccxml(Function-variadic)
@@ -151,6 +152,7 @@ castxml_test_gccxml(FunctionType-variadic)
castxml_test_gccxml(FundamentalType)
castxml_test_gccxml(FundamentalTypes)
castxml_test_gccxml(Method)
+castxml_test_gccxml(Method-rvalue-reference)
castxml_test_gccxml(MethodType)
castxml_test_gccxml(MethodType-cv)
castxml_test_gccxml(Namespace)
diff --git a/test/expect/gccxml.any.Function-rvalue-reference.stdout.txt b/test/expect/gccxml.any.Function-rvalue-reference.stdout.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/test/expect/gccxml.any.Function-rvalue-reference.stdout.txt
@@ -0,0 +1 @@
+^$
diff --git a/test/expect/gccxml.any.Function-rvalue-reference.xml.txt b/test/expect/gccxml.any.Function-rvalue-reference.xml.txt
new file mode 100644
index 0000000..4046f2e
--- /dev/null
+++ b/test/expect/gccxml.any.Function-rvalue-reference.xml.txt
@@ -0,0 +1,9 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Function id="_1" name="start" returns="_2" context="_3" location="f1:1" file="f1" line="1">
+ <Argument type="_2" location="f1:1" file="f1" line="1"/>
+ </Function>
+ <FundamentalType id="_2" name="int"/>
+ <Namespace id="_3" name="::"/>
+ <File id="f1" name=".*/test/input/Function-rvalue-reference.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.any.Method-rvalue-reference.stdout.txt b/test/expect/gccxml.any.Method-rvalue-reference.stdout.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/test/expect/gccxml.any.Method-rvalue-reference.stdout.txt
@@ -0,0 +1 @@
+^$
diff --git a/test/expect/gccxml.any.Method-rvalue-reference.xml.txt b/test/expect/gccxml.any.Method-rvalue-reference.xml.txt
new file mode 100644
index 0000000..db9828b
--- /dev/null
+++ b/test/expect/gccxml.any.Method-rvalue-reference.xml.txt
@@ -0,0 +1,18 @@
+^<\?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"/>
+ <Constructor id="_3" name="start" context="_1" access="private" location="f1:2" file="f1" line="2">
+ <Argument type="_7" location="f1:2" file="f1" line="2"/>
+ </Constructor>
+ <OperatorMethod id="_4" name="=" returns="_7" context="_1" access="private" location="f1:4" file="f1" line="4">
+ <Argument type="_7" location="f1:4" file="f1" line="4"/>
+ </OperatorMethod>
+ <Method id="_5" name="method" returns="_8" context="_1" access="private" location="f1:6" file="f1" line="6">
+ <Argument type="_8" location="f1:6" file="f1" line="6"/>
+ </Method>
+ <Destructor id="_6" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"/>
+ <ReferenceType id="_7" type="_1"/>
+ <FundamentalType id="_8" name="int"/>
+ <Namespace id="_2" name="::"/>
+ <File id="f1" name=".*/test/input/Method-rvalue-reference.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.c++11.Function-rvalue-reference.stderr.txt b/test/expect/gccxml.c++11.Function-rvalue-reference.stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/test/expect/gccxml.c++11.Function-rvalue-reference.stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/test/expect/gccxml.c++11.Method-rvalue-reference.stderr.txt b/test/expect/gccxml.c++11.Method-rvalue-reference.stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/test/expect/gccxml.c++11.Method-rvalue-reference.stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/test/expect/gccxml.c++98.Function-rvalue-reference.stderr.txt b/test/expect/gccxml.c++98.Function-rvalue-reference.stderr.txt
new file mode 100644
index 0000000..6dbbb9d
--- /dev/null
+++ b/test/expect/gccxml.c++98.Function-rvalue-reference.stderr.txt
@@ -0,0 +1 @@
+warning: rvalue references are a C\+\+11 extension
diff --git a/test/expect/gccxml.c++98.Method-rvalue-reference.stderr.txt b/test/expect/gccxml.c++98.Method-rvalue-reference.stderr.txt
new file mode 100644
index 0000000..6dbbb9d
--- /dev/null
+++ b/test/expect/gccxml.c++98.Method-rvalue-reference.stderr.txt
@@ -0,0 +1 @@
+warning: rvalue references are a C\+\+11 extension
diff --git a/test/input/Function-rvalue-reference.cxx b/test/input/Function-rvalue-reference.cxx
new file mode 100644
index 0000000..9a68fd7
--- /dev/null
+++ b/test/input/Function-rvalue-reference.cxx
@@ -0,0 +1,3 @@
+int start(int);
+int start(int&&);
+int&& start(int, int);
diff --git a/test/input/Method-rvalue-reference.cxx b/test/input/Method-rvalue-reference.cxx
new file mode 100644
index 0000000..30c12ee
--- /dev/null
+++ b/test/input/Method-rvalue-reference.cxx
@@ -0,0 +1,9 @@
+class start {
+ start(start&);
+ start(start&&);
+ start& operator=(start&);
+ start& operator=(start&&);
+ int method(int);
+ int method(int&&);
+ int&& method(int, int);
+};