From 0e8d69fa7df1e238bc82b08d37babe9cd4cb5f5d Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Jul 2014 18:48:18 +0200 Subject: Make configmgr loplugin:salbool-clean Change-Id: Ib1f33387c50bcd853140eb2fc46995d23d7f367b --- compilerplugins/clang/salbool.cxx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx index 6ef85b39e147..f8ae35e41957 100644 --- a/compilerplugins/clang/salbool.cxx +++ b/compilerplugins/clang/salbool.cxx @@ -70,23 +70,19 @@ OverrideKind getOverrideKind(FunctionDecl const * decl) { //TODO: current implementation is not at all general, just tests what we // encounter in practice: -bool hasBoolOverload(FunctionDecl const * decl) { - if (isa(decl)) { - unsigned n = decl->getNumParams(); - CXXRecordDecl const * r = dyn_cast( - decl->getDeclContext()); - assert(r != nullptr); - for (auto m = r->method_begin(); m != r->method_end(); ++m) { - if (m->getDeclName() == decl->getDeclName() - && m->getNumParams() == n) - { +bool hasBoolOverload(FunctionDecl const * decl, bool mustBeDeleted) { + unsigned n = decl->getNumParams(); + for (auto d: decl->getDeclContext()->lookup(decl->getDeclName())) { + FunctionDecl const * f = dyn_cast(d); + if (f != nullptr && (!mustBeDeleted || f->isDeleted())) { + if (f->getNumParams() == n) { bool hasSB = false; for (unsigned i = 0; i != n; ++i) { QualType t1 { decl->getParamDecl(i)->getType() }; bool isSB = isSalBool(t1); bool isSBRef = !isSB && t1->isReferenceType() && isSalBool(t1.getNonReferenceType()); - QualType t2 { m->getParamDecl(i)->getType() }; + QualType t2 { f->getParamDecl(i)->getType() }; if (!(isSB ? t2->isBooleanType() : isSBRef @@ -286,8 +282,8 @@ bool SalBool::VisitParmVarDecl(ParmVarDecl const * decl) { f->getNameInfo().getLoc())) && (!f->isInlined() || f->hasAttr() || decl->getType()->isReferenceType() - || hasBoolOverload(f))) - || f->isDeleted())) + || hasBoolOverload(f, false))) + || f->isDeleted() || hasBoolOverload(f, true))) { OverrideKind k = getOverrideKind(f); if (k != OverrideKind::YES) { -- cgit v1.2.3