From c03efa7c6c28a7c7f3dc2c45c9c56412e270fb5d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 21 May 2014 08:32:01 +0200 Subject: 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 --- compilerplugins/clang/passstuffbyref.cxx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx index 7ad891728238..51e324a774c6 100644 --- a/compilerplugins/clang/passstuffbyref.cxx +++ b/compilerplugins/clang/passstuffbyref.cxx @@ -39,6 +39,13 @@ bool PassStuffByRef::VisitFunctionDecl(const FunctionDecl * functionDecl) { if (functionDecl->isThisDeclarationADefinition() && functionDecl->getPreviousDecl() != nullptr) { return true; } + // only consider base declarations, not overriden ones, or we warn on methods that + // are overriding stuff from external libraries + if (isa(functionDecl)) { + CXXMethodDecl const * m = dyn_cast(functionDecl); + if (m->size_overridden_methods() > 0) + return true; + } unsigned n = functionDecl->getNumParams(); for (unsigned i = 0; i != n; ++i) { const ParmVarDecl * pvDecl = functionDecl->getParamDecl(i); -- cgit