summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-05-21 08:32:01 +0200
committerNoel Grandin <noel@peralex.com>2014-05-22 07:54:54 +0200
commitc03efa7c6c28a7c7f3dc2c45c9c56412e270fb5d (patch)
tree8b92fa28df98cede49ecc13fa302eaf626215838 /compilerplugins
parent05d7608616351cb6f5a9e06398c545813947006c (diff)
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
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/passstuffbyref.cxx7
1 files changed, 7 insertions, 0 deletions
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<CXXMethodDecl>(functionDecl)) {
+ CXXMethodDecl const * m = dyn_cast<CXXMethodDecl>(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);