summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-12-16 15:16:37 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-12-16 15:16:37 +0100
commit9d7802e7fc055d5d4d28fcf01461e8a7dbe208a0 (patch)
treec0d3dc721aa3714467084d2ef94c1e7826c682ae /compilerplugins
parentb998313d9d1ec511eff5076029e62608c8c5ca0e (diff)
Make move detection in loplugin::passstuffbyref work for parenthesized cases
Change-Id: I56754a718af9433c0fa654ccb8eb34da00e75420
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/passstuffbyref.cxx2
-rw-r--r--compilerplugins/clang/test/passstuffbyref.cxx11
2 files changed, 7 insertions, 6 deletions
diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx
index fca6b7375a07..8bbea52fc790 100644
--- a/compilerplugins/clang/passstuffbyref.cxx
+++ b/compilerplugins/clang/passstuffbyref.cxx
@@ -201,7 +201,7 @@ void PassStuffByRef::checkParams(const FunctionDecl * functionDecl) {
for (CXXCtorInitializer const * cxxCtorInitializer : cxxConstructorDecl->inits()) {
if (cxxCtorInitializer->isMemberInitializer())
{
- auto cxxConstructExpr = dyn_cast<CXXConstructExpr>(cxxCtorInitializer->getInit());
+ auto cxxConstructExpr = dyn_cast<CXXConstructExpr>(cxxCtorInitializer->getInit()->IgnoreParenImpCasts());
if (cxxConstructExpr && cxxConstructExpr->getNumArgs() == 1)
{
if (auto callExpr = dyn_cast<CallExpr>(cxxConstructExpr->getArg(0)->IgnoreParenImpCasts())) {
diff --git a/compilerplugins/clang/test/passstuffbyref.cxx b/compilerplugins/clang/test/passstuffbyref.cxx
index d871c5be112c..7c31af77df77 100644
--- a/compilerplugins/clang/test/passstuffbyref.cxx
+++ b/compilerplugins/clang/test/passstuffbyref.cxx
@@ -10,19 +10,20 @@
#include <rtl/ustring.hxx>
struct S {
- OUString mv;
+ OUString mv1;
+ OUString mv2;
// make sure we ignore cases where the passed in parameter is std::move'd
- S(OUString v)
- : mv(std::move(v)) {}
+ S(OUString v1, OUString v2)
+ : mv1(std::move(v1)), mv2((std::move(v2))) {}
};
void f() // expected-error {{Unreferenced externally visible function definition [loplugin:unreffun]}}
{
S* s;
- OUString v;
- s = new S(v);
+ OUString v1, v2;
+ s = new S(v1, v2);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */