From aeb49468598774f683f1bc8bb50bd0e301a80fa3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 11 Apr 2014 11:09:21 -0400 Subject: 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. --- src/Output.cxx | 23 +++++++++++----------- test/CMakeLists.txt | 2 ++ ...gccxml.any.Function-rvalue-reference.stdout.txt | 1 + .../gccxml.any.Function-rvalue-reference.xml.txt | 9 +++++++++ .../gccxml.any.Method-rvalue-reference.stdout.txt | 1 + .../gccxml.any.Method-rvalue-reference.xml.txt | 18 +++++++++++++++++ ...cxml.c++11.Function-rvalue-reference.stderr.txt | 1 + ...gccxml.c++11.Method-rvalue-reference.stderr.txt | 1 + ...cxml.c++98.Function-rvalue-reference.stderr.txt | 1 + ...gccxml.c++98.Method-rvalue-reference.stderr.txt | 1 + test/input/Function-rvalue-reference.cxx | 3 +++ test/input/Method-rvalue-reference.cxx | 9 +++++++++ 12 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 test/expect/gccxml.any.Function-rvalue-reference.stdout.txt create mode 100644 test/expect/gccxml.any.Function-rvalue-reference.xml.txt create mode 100644 test/expect/gccxml.any.Method-rvalue-reference.stdout.txt create mode 100644 test/expect/gccxml.any.Method-rvalue-reference.xml.txt create mode 100644 test/expect/gccxml.c++11.Function-rvalue-reference.stderr.txt create mode 100644 test/expect/gccxml.c++11.Method-rvalue-reference.stderr.txt create mode 100644 test/expect/gccxml.c++98.Function-rvalue-reference.stderr.txt create mode 100644 test/expect/gccxml.c++98.Method-rvalue-reference.stderr.txt create mode 100644 test/input/Function-rvalue-reference.cxx create mode 100644 test/input/Method-rvalue-reference.cxx 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(d)) { if (fd->isDeleted()) { return 0; - } else if (clang::CXXMethodDecl const* md = - clang::dyn_cast(fd)) { - if (md->isImplicit()) { - if (clang::CXXConstructorDecl const* cd = - clang::dyn_cast(md)) { - if (cd->isMoveConstructor()) { - return 0; - } - } else if (md->isMoveAssignmentOperator()) { - return 0; - } + } + + clang::FunctionProtoType const* fpt = + fd->getType()->getAs(); + 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"\?> +]*> + + + + + + +$ 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"\?> +]*> + + + + + + + + + + + + + + + +$ 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); +}; -- cgit v0.12