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

Stephan Bergmann sbergman at redhat.com
Thu Oct 26 19:07:49 UTC 2017


 compilerplugins/clang/implicitboolconversion.cxx |   26 +++++++++++++++++++++++
 1 file changed, 26 insertions(+)

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

    Make loplugin:implicitboolconversion find the same in C++17 and pre-C++17
    
    ...see a2d814ac1d7beb6fbe4b9cb7b75814f4b08b8e59
    "loplugin:implicitboolconversion" and 24eeb4d286471e4a2103c15efc624a565112ca32
    "loplugin:implicitboolconversion" for things previously only found in C++17.  As
    expected, no further occurrences were found.
    
    Change-Id: Id0ab621b82dc3c40c8b5801413fceb73ade1408a

diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index bc18e87cf366..058e042dbcf2 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -284,6 +284,8 @@ public:
 
     bool VisitImplicitCastExpr(ImplicitCastExpr const * expr);
 
+    bool VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr const * expr);
+
 private:
     bool isExternCFunctionCall(
         CallExpr const * expr, FunctionProtoType const ** functionType);
@@ -905,6 +907,30 @@ bool ImplicitBoolConversion::VisitImplicitCastExpr(
     return true;
 }
 
+bool ImplicitBoolConversion::VisitMaterializeTemporaryExpr(
+    MaterializeTemporaryExpr const * expr)
+{
+    if (ignoreLocation(expr)) {
+        return true;
+    }
+    if (auto const sub = dyn_cast<ExplicitCastExpr>(expr->GetTemporaryExpr())) {
+        auto const subsub = compat::getSubExprAsWritten(sub);
+        if (subsub->getType().IgnoreParens() == expr->getType().IgnoreParens()
+            && isBool(subsub))
+        {
+            report(
+                DiagnosticsEngine::Warning,
+                ("explicit conversion (%0) from %1 to %2 implicitly converted"
+                 " back to %3"),
+                expr->getLocStart())
+                << sub->getCastKindName() << subsub->getType() << sub->getType()
+                << expr->getType() << expr->getSourceRange();
+            return true;
+        }
+    }
+    return true;
+}
+
 bool ImplicitBoolConversion::isExternCFunctionCall(
     CallExpr const * expr, FunctionProtoType const ** functionType)
 {


More information about the Libreoffice-commits mailing list