summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/refcounting.cxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-03-06 14:39:13 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-03-11 11:53:50 +0100
commit990163534cb5bc63ac500d5204f4caeab056bdf3 (patch)
treef48378c04d3c0a4c55fc07290c2d09be2ddc1b16 /compilerplugins/clang/refcounting.cxx
parent803b43efe86b51366a516648015efd3b39255f75 (diff)
move isDerivedFrom() from a clang plugin to shared code, for reuse
Change-Id: I7b9b41a7081281214a387cdf02080866e9b9dfe7 Reviewed-on: https://gerrit.libreoffice.org/68873 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/refcounting.cxx')
-rw-r--r--compilerplugins/clang/refcounting.cxx33
1 files changed, 1 insertions, 32 deletions
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 6ae861cfcad9..535808a3a0ca 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -35,7 +35,7 @@ not delete on last 'release'.
*/
-namespace {
+namespace loplugin {
class RefCounting:
public loplugin::FilteringPlugin<RefCounting>
@@ -72,37 +72,6 @@ private:
bool visitTemporaryObjectExpr(Expr const * expr);
};
-typedef std::function<bool(Decl const *)> DeclChecker;
-
-bool BaseCheckNotSubclass(const CXXRecordDecl *BaseDefinition, void *p) {
- if (!BaseDefinition)
- return true;
- auto const & base = *static_cast<const DeclChecker *>(p);
- if (base(BaseDefinition)) {
- return false;
- }
- return true;
-}
-
-bool isDerivedFrom(const CXXRecordDecl *decl, DeclChecker base) {
- if (!decl)
- return false;
- if (base(decl))
- return true;
- if (!decl->hasDefinition()) {
- return false;
- }
- if (!decl->forallBases(
- [&base](const CXXRecordDecl *BaseDefinition) -> bool
- { return BaseCheckNotSubclass(BaseDefinition, &base); },
- true))
- {
- return true;
- }
- return false;
-}
-
-
bool containsXInterfaceSubclass(const clang::Type* pType0);
bool containsXInterfaceSubclass(const QualType& qType) {