diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-02 15:10:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-03 08:07:41 +0100 |
commit | acdba3c2eee18ef0c079b7c41cd4165e06c956c7 (patch) | |
tree | 18c6da7b7d46bf901b6dd4f7a5b280caa7f62280 /compilerplugins/clang/passstuffbyref.cxx | |
parent | f4bd9029ba7b500ebf99b7fa3d774de7fa029176 (diff) |
loplugin:passstuffbyref more return improvements
slightly less restrictive check when calling functions
Change-Id: I35e268ac611797b1daa83777cda02288a635aa32
Reviewed-on: https://gerrit.libreoffice.org/47259
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/passstuffbyref.cxx')
-rw-r--r-- | compilerplugins/clang/passstuffbyref.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx index 54982fdfc045..8cfae946f041 100644 --- a/compilerplugins/clang/passstuffbyref.cxx +++ b/compilerplugins/clang/passstuffbyref.cxx @@ -275,7 +275,7 @@ void PassStuffByRef::checkReturnValue(const FunctionDecl * functionDecl, const C return; } - //functionDecl->dump(); + // functionDecl->dump(); mbInsideFunctionDecl = true; mbFoundReturnValueDisqualifier = false; @@ -412,12 +412,14 @@ bool PassStuffByRef::isReturnExprDisqualified(const Expr* expr) FunctionDecl const * calleeFunctionDecl = callExpr->getDirectCallee(); if (!calleeFunctionDecl) return true; - // TODO anything takes a param is suspect because it might return the param by ref. + // TODO anything takes a non-integral param is suspect because it might return the param by ref. // we could tighten this to only reject functions that have a param of the same type // as the return type. Or we could check for such functions and disallow them. // Or we could force such functions to be annotated somehow. - if (calleeFunctionDecl->getNumParams() > 0) - return true; + for (unsigned i = 0; i != calleeFunctionDecl->getNumParams(); ++i) { + if (!calleeFunctionDecl->getParamDecl(i)->getType()->isIntegralOrEnumerationType()) + return true; + } auto tc = loplugin::TypeCheck(calleeFunctionDecl->getReturnType()); if (!tc.LvalueReference() && !tc.Pointer()) return true; |