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

Stephan Bergmann sbergman at redhat.com
Thu Oct 26 19:04:42 UTC 2017


 compilerplugins/clang/implicitboolconversion.cxx |   39 +++++++++++------------
 1 file changed, 20 insertions(+), 19 deletions(-)

New commits:
commit e02e0f4081c0807fa65548159292585c680abff3
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Oct 26 21:04:03 2017 +0200

    Use compat::getSubExprAsWritten; clean up
    
    Change-Id: I8f984c3b3833437f6b4d65ab99da608a6868ff74

diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index 1151a78f4384..bc18e87cf366 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -859,29 +859,30 @@ bool ImplicitBoolConversion::VisitImplicitCastExpr(
         }
         return true;
     }
-    ExplicitCastExpr const * sub = dyn_cast<ExplicitCastExpr>(
-        expr->getSubExpr()->IgnoreParenImpCasts());
-    if (sub != nullptr
-        && (sub->getSubExpr()->IgnoreParenImpCasts()->getType().IgnoreParens()
-            == expr->getType().IgnoreParens())
-        && isBool(sub->getSubExpr()->IgnoreParenImpCasts()))
+    if (auto const sub = dyn_cast<ExplicitCastExpr>(
+            compat::getSubExprAsWritten(expr)))
     {
-        // Ignore "normalizing cast" bool(b) from sal_Bool b to bool, then
-        // implicitly cast back again to sal_Bool:
-        if (dyn_cast<CXXFunctionalCastExpr>(sub) != nullptr
-            && sub->getType()->isBooleanType() && isSalBool(expr->getType())
-            && isSalBool(sub->getSubExpr()->IgnoreParenImpCasts()->getType()))
+        auto const subsub = compat::getSubExprAsWritten(sub);
+        if (subsub->getType().IgnoreParens() == expr->getType().IgnoreParens()
+            && isBool(subsub))
         {
+            // Ignore "normalizing cast" bool(b) from sal_Bool b to bool, then
+            // implicitly cast back again to sal_Bool:
+            if (dyn_cast<CXXFunctionalCastExpr>(sub) != nullptr
+                && sub->getType()->isBooleanType() && isSalBool(expr->getType())
+                && isSalBool(subsub->getType()))
+            {
+                return true;
+            }
+            report(
+                DiagnosticsEngine::Warning,
+                ("explicit conversion (%0) from %1 to %2 implicitly cast back"
+                 " to %3"),
+                expr->getLocStart())
+                << sub->getCastKindName() << subsub->getType() << sub->getType()
+                << expr->getType() << expr->getSourceRange();
             return true;
         }
-        report(
-            DiagnosticsEngine::Warning,
-            "explicit conversion (%0) from %1 to %2 implicitly cast back to %3",
-            expr->getLocStart())
-            << sub->getCastKindName()
-            << sub->getSubExpr()->IgnoreParenImpCasts()->getType()
-            << sub->getType() << expr->getType() << expr->getSourceRange();
-        return true;
     }
     if (expr->getType()->isBooleanType() && !isBoolExpr(expr->getSubExpr())
         && !calls.empty())


More information about the Libreoffice-commits mailing list