compilerplugins/clang/blockblock.cxx      |   45 ++----------------------------
 compilerplugins/clang/test/blockblock.cxx |    8 +++--
 2 files changed, 8 insertions(+), 45 deletions(-)

New commits:
commit 1084e8be44661aaeacb8801707701013eb3fcdbc
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Wed Oct 4 12:03:23 2017 +0200

    More targeted check for preprocessing conditionals in loplugin:blockblock
    
    Change-Id: Ib9b6b266ed4bf4d2672aed723c7f92f58c9007b3

diff --git a/compilerplugins/clang/blockblock.cxx 
b/compilerplugins/clang/blockblock.cxx
index a4ac7ffb8edb..7d274059fedf 100644
--- a/compilerplugins/clang/blockblock.cxx
+++ b/compilerplugins/clang/blockblock.cxx
@@ -35,48 +35,6 @@ public:
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
     }
 
-    bool TraverseFunctionDecl(FunctionDecl * decl) {
-        if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) 
{
-            return true;
-        }
-        return RecursiveASTVisitor::TraverseFunctionDecl(decl);
-    }
-
-    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 * );
 };
 
@@ -93,6 +51,9 @@ bool BlockBlock::VisitCompoundStmt(CompoundStmt const * 
compound)
         return true;
     if (compiler.getSourceManager().isMacroBodyExpansion(inner->getLocStart()))
         return true;
+    if (containsPreprocessingConditionalInclusion(compound->getSourceRange())) 
{
+        return true;
+    }
     report(
         DiagnosticsEngine::Warning,
         "block directly inside block",
diff --git a/compilerplugins/clang/test/blockblock.cxx 
b/compilerplugins/clang/test/blockblock.cxx
index 2463ccaa7fd5..bd48ed7d38fa 100644
--- a/compilerplugins/clang/test/blockblock.cxx
+++ b/compilerplugins/clang/test/blockblock.cxx
@@ -8,12 +8,14 @@
  */
 
 int f(bool b1, bool b2) {
-    if (b1 || b2) {
+    if (b1 || b2) { // no warning
 #if 0
         if (b1)
 #endif
-        {
-            return 0;
+        { // expected-error {{block directly inside block 
[loplugin:blockblock]}}
+            { // expected-note {{inner block here [loplugin:blockblock]}}
+                return 0;
+            }
         }
     }
     return 1;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to