summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/passstuffbyref.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-12-05 23:00:58 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-12-06 11:37:06 +0100
commit37fe0f729c17bd30d9f273b268b15c353c34a156 (patch)
treeeda465e1a0ec6a9c32b1d6a75e4a12d37d09272d /compilerplugins/clang/passstuffbyref.cxx
parente6f38aed7c4d6f9a2fd20a3b8eba9083afcc67a2 (diff)
Better heuristic to only look through implicit copy/move ctors
At least recent libc++ has a std::string ctor overload without a (defaulted) Allocator argument (which otherwise causes creation of a temporary Allocator object and thus a ExprWithCleanups), so in C++17 mode (i.e., with no implicit move CXXConstructExpr -> MaterializeTemporaryExpr -> CXXBindTemporaryExpr chain in the way) CellInfo::toString (sw/source/filter/ww8/WW8TableInfo.cxx) has a ReturnStmt of just > ReturnStmt > `-ImplicitCastExpr 'std::string':'class std::__1::basic_string<char>' <ConstructorConversion> > `-CXXConstructExpr 'std::string':'class std::__1::basic_string<char>' 'void (const char *)' > `-ImplicitCastExpr 'const char *' <NoOp> > `-ImplicitCastExpr 'char *' <ArrayToPointerDecay> > `-DeclRefExpr 'char [256]' lvalue Var 'sBuffer' 'char [256]' that erroneously triggered loplugin:passstuffbyref. Change-Id: I53c8911cb1356560692c003808280a103c399e25 Reviewed-on: https://gerrit.libreoffice.org/45916 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/passstuffbyref.cxx')
-rw-r--r--compilerplugins/clang/passstuffbyref.cxx7
1 files changed, 5 insertions, 2 deletions
diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx
index f87e668ed4fa..3b4b974c697f 100644
--- a/compilerplugins/clang/passstuffbyref.cxx
+++ b/compilerplugins/clang/passstuffbyref.cxx
@@ -310,8 +310,11 @@ bool PassStuffByRef::isReturnExprDisqualified(const Expr* expr)
if (isa<ExprWithCleanups>(expr)) {
return true;
}
- if (const CXXConstructExpr* constructExpr = dyn_cast<CXXConstructExpr>(expr)) {
- if (constructExpr->getNumArgs()==1) {
+ if (const CXXConstructExpr* constructExpr = dyn_cast<CXXConstructExpr>(expr))
+ {
+ if (constructExpr->getNumArgs()==1
+ && constructExpr->getConstructor()->isCopyOrMoveConstructor())
+ {
expr = constructExpr->getArg(0)->IgnoreParenCasts();
}
}