[Libreoffice-commits] core.git: compilerplugins/clang

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Mon Apr 12 10:39:17 UTC 2021


 compilerplugins/clang/selfinit.cxx                  |   41 +++++++++++++++-----
 compilerplugins/clang/sharedvisitor/dummyplugin.hxx |    2 
 compilerplugins/clang/unsignedcompare.cxx           |    6 ++
 compilerplugins/clang/unusedmember.cxx              |    2 
 compilerplugins/clang/vclwidgets.cxx                |    2 
 5 files changed, 42 insertions(+), 11 deletions(-)

New commits:
commit 4eac7a11e5d39ca6c783f65f1ca2df009b9a37e4
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Apr 9 17:16:11 2021 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Apr 12 12:38:37 2021 +0200

    convert few more clang plugins to shared
    
    Change-Id: If8ee55d36f1fd2b2dee8c0a1596dee0c7d05eb6f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113886
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/compilerplugins/clang/selfinit.cxx b/compilerplugins/clang/selfinit.cxx
index 35ce37278f2a..3891a5fc724f 100644
--- a/compilerplugins/clang/selfinit.cxx
+++ b/compilerplugins/clang/selfinit.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 #include <vector>
 
 #include "plugin.hxx"
@@ -24,28 +26,45 @@ public:
     {
     }
 
-    bool TraverseVarDecl(VarDecl* decl)
+    bool PreTraverseVarDecl(VarDecl* decl)
     {
         decls_.push_back({ decl, decl->getCanonicalDecl() });
-        auto const ret = FilteringPlugin::TraverseVarDecl(decl);
+        return true;
+    }
+    bool PostTraverseVarDecl(VarDecl*, bool)
+    {
         decls_.pop_back();
+        return true;
+    }
+    bool TraverseVarDecl(VarDecl* decl)
+    {
+        PreTraverseVarDecl(decl);
+        auto const ret = FilteringPlugin::TraverseVarDecl(decl);
+        PostTraverseVarDecl(decl, ret);
         return ret;
     }
 
-    bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr* expr)
+    bool PreTraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr* expr)
     {
         if (expr->getKind() == UETT_SizeOf)
-        {
-            return true;
-        }
-        return FilteringPlugin::TraverseUnaryExprOrTypeTraitExpr(expr);
+            return false;
+        return true;
+    }
+    bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr* expr)
+    {
+        if (PreTraverseUnaryExprOrTypeTraitExpr(expr))
+            return FilteringPlugin::TraverseUnaryExprOrTypeTraitExpr(expr);
+        return true;
     }
 
-    bool TraverseCXXTypeidExpr(CXXTypeidExpr const*) { return true; }
+    bool TraverseCXXTypeidExpr(CXXTypeidExpr*) { return true; }
+    bool PreTraverseCXXTypeidExpr(CXXTypeidExpr*) { return false; }
 
-    bool TraverseCXXNoexceptExpr(CXXNoexceptExpr const*) { return true; }
+    bool TraverseCXXNoexceptExpr(CXXNoexceptExpr*) { return true; }
+    bool PreTraverseCXXNoexceptExpr(CXXNoexceptExpr*) { return false; }
 
     bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; }
+    bool PreTraverseDecltypeTypeLoc(DecltypeTypeLoc) { return false; }
 
     bool VisitDeclRefExpr(DeclRefExpr const* expr)
     {
@@ -82,7 +101,9 @@ private:
     std::vector<Decl> decls_;
 };
 
-loplugin::Plugin::Registration<SelfInit> X("selfinit");
+loplugin::Plugin::Registration<SelfInit> selfinit("selfinit");
 }
 
+#endif // LO_CLANG_SHARED_PLUGINS
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/sharedvisitor/dummyplugin.hxx b/compilerplugins/clang/sharedvisitor/dummyplugin.hxx
index 0ccc36dc86c9..1ef87416a907 100644
--- a/compilerplugins/clang/sharedvisitor/dummyplugin.hxx
+++ b/compilerplugins/clang/sharedvisitor/dummyplugin.hxx
@@ -56,6 +56,8 @@ public:
     bool TraverseFriendDecl( FriendDecl* ) { return complain(); }
     bool TraverseTypeLoc( TypeLoc ) { return complain(); }
     bool TraverseAlignedAttr( AlignedAttr* ) { return complain(); }
+    bool TraverseVarDecl( VarDecl* ) { return complain(); }
+    bool TraverseUnaryExprOrTypeTraitExpr( UnaryExprOrTypeTraitExpr* ) { return complain(); }
 private:
     bool complain() { assert(false && "should not be calling this in sharedplugin mode"); abort(); return false; }
 };
diff --git a/compilerplugins/clang/unsignedcompare.cxx b/compilerplugins/clang/unsignedcompare.cxx
index 7337f45223d4..f231db0858f4 100644
--- a/compilerplugins/clang/unsignedcompare.cxx
+++ b/compilerplugins/clang/unsignedcompare.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef LO_CLANG_SHARED_PLUGINS
+
 // Find explicit casts from signed to unsigned integer in comparison against unsigned integer, where
 // the cast is presumably used to avoid warnings about signed vs. unsigned comparisons, and could
 // thus be replaced with o3tl::make_unsigned for clarity.
@@ -163,7 +165,6 @@ public:
         return true;
     }
 
-private:
     bool preRun() override
     {
         return compiler.getLangOpts().CPlusPlus
@@ -180,6 +181,7 @@ private:
         }
     }
 
+private:
     ExplicitCastExpr const* isCastToUnsigned(Expr const* expr)
     {
         auto const e = dyn_cast<ExplicitCastExpr>(expr->IgnoreParenImpCasts());
@@ -230,4 +232,6 @@ private:
 loplugin::Plugin::Registration<UnsignedCompare> unsignedcompare("unsignedcompare");
 }
 
+#endif // LO_CLANG_SHARED_PLUGINS
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/unusedmember.cxx b/compilerplugins/clang/unusedmember.cxx
index 1d3017134892..bfd4f591616d 100644
--- a/compilerplugins/clang/unusedmember.cxx
+++ b/compilerplugins/clang/unusedmember.cxx
@@ -459,4 +459,6 @@ private:
 loplugin::Plugin::Registration<UnusedMember> unusedmember("unusedmember");
 }
 
+// Cannot be shared, uses TraverseStmt().
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 61805ff5ad03..92bc4a0c3911 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -868,4 +868,6 @@ loplugin::Plugin::Registration< VCLWidgets > vclwidgets("vclwidgets");
 
 }
 
+// Cannot be shared, uses TraverseStmt().
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list