Kaydet (Commit) c03efa7c authored tarafından Noel Grandin's avatar Noel Grandin

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
üst 05d76086
...@@ -39,6 +39,13 @@ bool PassStuffByRef::VisitFunctionDecl(const FunctionDecl * functionDecl) { ...@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment