summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-24 17:27:18 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-24 17:27:18 +0200
commite6daf6bfb0c3c3e3ba03c825d778436c369f19a3 (patch)
tree0c898d430bea65dd4d41ab58e28bd3082b23ddd8
parent81db0773fe499fd4b326925dad42a7099f19fcb3 (diff)
Fix check for calls to OWeakObject::release
Change-Id: I90030dee12676eb356ebe2244358052cfcd725de
-rw-r--r--compilerplugins/clang/weakobject.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/compilerplugins/clang/weakobject.cxx b/compilerplugins/clang/weakobject.cxx
index 42bdf6e16481..cac13cdcc7db 100644
--- a/compilerplugins/clang/weakobject.cxx
+++ b/compilerplugins/clang/weakobject.cxx
@@ -106,16 +106,23 @@ public:
{
// note: this is only sometimes a CXXMethodDecl
FunctionDecl const*const pCalled(pCallExpr->getDirectCallee());
- if (pCalled->getName() == "release"
-//this never works && pCalled == pOverridden
- && (pCalled->getParent() == pOverridden->getParent()
- // allow this convenient shortcut
- || loplugin::TypeCheck(QualType(pMethodDecl->getParent()->getTypeForDecl(), 0)).Class("OWeakObject").Namespace("cppu")
- || loplugin::TypeCheck(QualType(pMethodDecl->getParent()->getTypeForDecl(), 0)).Class("OWeakAggObject").Namespace("cppu")))
+ if (pCalled->getName() == "release")
{
- return true;
+//this never works && pCalled == pOverridden
+ if (pCalled->getParent() == pOverridden->getParent())
+ {
+ return true;
+ }
+ // Allow this convenient shortcut:
+ auto td = dyn_cast<TypeDecl>(pCalled->getParent());
+ if (td != nullptr
+ && (loplugin::TypeCheck(QualType(td->getTypeForDecl(), 0)).Class("OWeakObject").Namespace("cppu")
+ || loplugin::TypeCheck(QualType(td->getTypeForDecl(), 0)).Class("OWeakAggObject").Namespace("cppu")))
+ {
+ return true;
+ }
}
- if (pCalled->getName() == "relase_ChildImpl") // FIXME remove this lunacy
+ else if (pCalled->getName() == "relase_ChildImpl") // FIXME remove this lunacy
{
return true;
}