loplugin-passbyref: ignore non-base declarations

Only consider base declarations, not overriden ones, or we warn on methods that
are overriding stuff from external libraries.

Change-Id: I08791c96f7adba5997ad237a98e7c08a759042ad
This commit is contained in:
Noel Grandin 2014-05-21 08:32:01 +02:00
parent 05d7608616
commit c03efa7c6c

View File

@ -39,6 +39,13 @@ bool PassStuffByRef::VisitFunctionDecl(const FunctionDecl * functionDecl) {
if (functionDecl->isThisDeclarationADefinition() && functionDecl->getPreviousDecl() != nullptr) { if (functionDecl->isThisDeclarationADefinition() && functionDecl->getPreviousDecl() != nullptr) {
return true; return true;
} }
// only consider base declarations, not overriden ones, or we warn on methods that
// are overriding stuff from external libraries
if (isa<CXXMethodDecl>(functionDecl)) {
CXXMethodDecl const * m = dyn_cast<CXXMethodDecl>(functionDecl);
if (m->size_overridden_methods() > 0)
return true;
}
unsigned n = functionDecl->getNumParams(); unsigned n = functionDecl->getNumParams();
for (unsigned i = 0; i != n; ++i) { for (unsigned i = 0; i != n; ++i) {
const ParmVarDecl * pvDecl = functionDecl->getParamDecl(i); const ParmVarDecl * pvDecl = functionDecl->getParamDecl(i);