diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-07-02 18:48:18 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-07-02 18:48:18 +0200 |
commit | 0e8d69fa7df1e238bc82b08d37babe9cd4cb5f5d (patch) | |
tree | 91aea1cbed1c6878e9c7c653703d95398754d5d7 /compilerplugins | |
parent | 3325e0f206ce864730468c3556ce06760042c157 (diff) |
Make configmgr loplugin:salbool-clean
Change-Id: Ib1f33387c50bcd853140eb2fc46995d23d7f367b
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/salbool.cxx | 22 |
1 files changed, 9 insertions, 13 deletions
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<CXXMethodDecl>(decl)) { - unsigned n = decl->getNumParams(); - CXXRecordDecl const * r = dyn_cast<CXXRecordDecl>( - 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<FunctionDecl>(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<DeprecatedAttr>() || decl->getType()->isReferenceType() - || hasBoolOverload(f))) - || f->isDeleted())) + || hasBoolOverload(f, false))) + || f->isDeleted() || hasBoolOverload(f, true))) { OverrideKind k = getOverrideKind(f); if (k != OverrideKind::YES) { |