[Libreoffice-commits] core.git: compilerplugins/clang
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Mar 11 10:54:13 UTC 2019
compilerplugins/clang/check.cxx | 29 +++++++++++++++++++++++++++++
compilerplugins/clang/check.hxx | 6 ++++++
compilerplugins/clang/refcounting.cxx | 33 +--------------------------------
3 files changed, 36 insertions(+), 32 deletions(-)
New commits:
commit 990163534cb5bc63ac500d5204f4caeab056bdf3
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed Mar 6 14:39:13 2019 +0100
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Mar 11 11:53:50 2019 +0100
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 at collabora.co.uk>
diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx
index acda74adacd6..f2443e44a1f2 100644
--- a/compilerplugins/clang/check.cxx
+++ b/compilerplugins/clang/check.cxx
@@ -280,6 +280,35 @@ bool isOkToRemoveArithmeticCast(
return true;
}
+
+static bool BaseCheckNotSubclass(const clang::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 clang::CXXRecordDecl *decl, DeclChecker base) {
+ if (!decl)
+ return false;
+ if (base(decl))
+ return true;
+ if (!decl->hasDefinition()) {
+ return false;
+ }
+ if (!decl->forallBases(
+ [&base](const clang::CXXRecordDecl *BaseDefinition) -> bool
+ { return BaseCheckNotSubclass(BaseDefinition, &base); },
+ true))
+ {
+ return true;
+ }
+ return false;
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/check.hxx b/compilerplugins/clang/check.hxx
index 4ae65f139955..0d636636a81a 100644
--- a/compilerplugins/clang/check.hxx
+++ b/compilerplugins/clang/check.hxx
@@ -140,6 +140,12 @@ private:
bool const satisfied_;
};
+
+typedef std::function<bool(clang::Decl const *)> DeclChecker;
+// Returns true if the class has a base matching the checker, or if the class itself matches.
+bool isDerivedFrom(const clang::CXXRecordDecl *decl, DeclChecker base);
+
+
namespace detail {
ContextCheck checkRecordDecl(
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) {
More information about the Libreoffice-commits
mailing list