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

Stephan Bergmann sbergman at redhat.com
Wed Oct 4 09:18:13 UTC 2017


 compilerplugins/clang/blockblock.cxx      |   35 ++++++++++++++++++++++++++++++
 compilerplugins/clang/test/blockblock.cxx |   11 +++++++++
 2 files changed, 46 insertions(+)

New commits:
commit 56c9446f74747214f733757f134cbc9e055ca5e2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 4 11:14:43 2017 +0200

    Suppress loplugin:blockblock in functions involving preprocessing conditionals
    
    ...as needed to avoid an unhelpful warning about Player::createPlayerWindow in
    avmedia/source/gstreamer/gstplayer.cxx when included from
    avmedia/source/gstreamer/gst_0_10.cxx (so that ENABLE_GTKSINK is not defined).
    
    Change-Id: I6de9cc59cf8e611c4c9d939dd837499b1d2c8787

diff --git a/compilerplugins/clang/blockblock.cxx b/compilerplugins/clang/blockblock.cxx
index 43e9b94deedb..3d5d69c2ab57 100644
--- a/compilerplugins/clang/blockblock.cxx
+++ b/compilerplugins/clang/blockblock.cxx
@@ -35,6 +35,41 @@ public:
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
     }
 
+    bool TraverseCXXMethodDecl(CXXMethodDecl * decl) {
+        if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+            return true;
+        }
+        return RecursiveASTVisitor::TraverseCXXMethodDecl(decl);
+    }
+
+    bool TraverseCXXConstructorDecl(CXXConstructorDecl * decl) {
+        if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+            return true;
+        }
+        return RecursiveASTVisitor::TraverseCXXConstructorDecl(decl);
+    }
+
+    bool TraverseCXXDestructorDecl(CXXDestructorDecl * decl) {
+        if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+            return true;
+        }
+        return RecursiveASTVisitor::TraverseCXXDestructorDecl(decl);
+    }
+
+    bool TraverseCXXConversionDecl(CXXConversionDecl * decl) {
+        if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+            return true;
+        }
+        return RecursiveASTVisitor::TraverseCXXConversionDecl(decl);
+    }
+
+    bool TraverseObjCMethodDecl(ObjCMethodDecl * decl) {
+        if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+            return true;
+        }
+        return RecursiveASTVisitor::TraverseObjCMethodDecl(decl);
+    }
+
     bool VisitCompoundStmt(CompoundStmt const * );
 };
 
diff --git a/compilerplugins/clang/test/blockblock.cxx b/compilerplugins/clang/test/blockblock.cxx
index d81f9fe527ae..89733103eb58 100644
--- a/compilerplugins/clang/test/blockblock.cxx
+++ b/compilerplugins/clang/test/blockblock.cxx
@@ -7,6 +7,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+int f(bool b1, bool b2) {
+    if (b1 || b2) {
+#if 1
+        if (b1)
+#endif
+        {
+            return 0;
+        }
+    }
+    return 1;
+}
 
 int main() { // expected-error {{block directly inside block [loplugin:blockblock]}}
     { // expected-note {{inner block here [loplugin:blockblock]}}


More information about the Libreoffice-commits mailing list