diff options
Diffstat (limited to 'compilerplugins/clang/passstuffbyref.cxx')
-rw-r--r-- | compilerplugins/clang/passstuffbyref.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx index 0630beb80b59..e152acec8673 100644 --- a/compilerplugins/clang/passstuffbyref.cxx +++ b/compilerplugins/clang/passstuffbyref.cxx @@ -402,6 +402,12 @@ 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. + // 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; auto tc = loplugin::TypeCheck(calleeFunctionDecl->getReturnType()); if (!tc.LvalueReference() && !tc.Pointer()) return true; |