[Libreoffice-commits] core.git: 17 commits - compilerplugins/clang cui/source dbaccess/source drawinglayer/source editeng/source extensions/source framework/source include/editeng opencl/source package/source reportdesign/source sc/qa sc/source sd/source stoc/source svx/source sw/source unoidl/source vcl/source

Stephan Bergmann sbergman at redhat.com
Fri Jun 2 07:39:17 UTC 2017


 compilerplugins/clang/redundantcast.cxx                    |   78 ++++++-
 compilerplugins/clang/salunicodeliteral.cxx                |   16 +
 compilerplugins/clang/test/redundantcast.cxx               |  141 ++++++++++++-
 compilerplugins/clang/test/redundantcast.hxx               |   35 +++
 compilerplugins/clang/test/salunicodeliteral.cxx           |    3 
 cui/source/options/treeopt.cxx                             |    6 
 dbaccess/source/core/dataaccess/ContentHelper.cxx          |    3 
 dbaccess/source/ui/browser/unodatbr.cxx                    |   10 
 dbaccess/source/ui/dlg/tablespage.cxx                      |    4 
 drawinglayer/source/primitive2d/svggradientprimitive2d.cxx |    2 
 editeng/source/editeng/eertfpar.cxx                        |    4 
 extensions/source/propctrlr/editpropertyhandler.cxx        |   12 -
 extensions/source/propctrlr/formcomponenthandler.cxx       |   44 ++--
 extensions/source/propctrlr/xsdvalidationhelper.cxx        |    2 
 framework/source/layoutmanager/layoutmanager.cxx           |    2 
 framework/source/layoutmanager/toolbarlayoutmanager.cxx    |    2 
 include/editeng/txtrange.hxx                               |    2 
 opencl/source/openclwrapper.cxx                            |    4 
 package/source/zippackage/ZipPackageStream.cxx             |    2 
 reportdesign/source/filter/xml/xmlExport.cxx               |   16 -
 sc/qa/unit/subsequent_filters-test.cxx                     |   12 -
 sc/qa/unit/ucalc.cxx                                       |   22 +-
 sc/qa/unit/ucalc_condformat.cxx                            |    2 
 sc/source/ui/optdlg/tpformula.cxx                          |    6 
 sc/source/ui/view/tabvwsh5.cxx                             |    2 
 sd/source/ui/unoidl/DrawController.cxx                     |    5 
 stoc/source/security/access_controller.cxx                 |    4 
 svx/source/svdraw/svdmodel.cxx                             |    4 
 svx/source/svdraw/svdoole2.cxx                             |    2 
 sw/source/core/doc/doccomp.cxx                             |    2 
 sw/source/core/text/frminf.cxx                             |    4 
 sw/source/core/text/txtftn.cxx                             |    2 
 sw/source/core/txtnode/ndtxt.cxx                           |    4 
 sw/source/core/undo/rolbck.cxx                             |    4 
 sw/source/core/undo/unredln.cxx                            |    4 
 sw/source/core/unocore/unoportenum.cxx                     |    2 
 sw/source/filter/ww8/ww8atr.cxx                            |    4 
 sw/source/uibase/shells/grfsh.cxx                          |    4 
 sw/source/uibase/shells/tabsh.cxx                          |    2 
 sw/source/uibase/sidebar/ThemePanel.cxx                    |    2 
 sw/source/uibase/uiview/view.cxx                           |    2 
 unoidl/source/legacyprovider.cxx                           |    2 
 vcl/source/gdi/pdfwriter_impl2.cxx                         |    2 
 43 files changed, 362 insertions(+), 125 deletions(-)

New commits:
commit beae2dd6c88d341f8c7de567c3da9fcc1ff423ab
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:38:15 2017 +0200

    Improved loplugin:redundantcast static_cast handling
    
    Change-Id: I74e4ebda40f95661c5ae344132fcabbbf08ab0a4

diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index de3353b295c1..93fb8a880ad4 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -66,6 +66,26 @@ bool isArithmeticOp(Expr const * expr) {
     return isa<UnaryOperator>(expr) || isa<AbstractConditionalOperator>(expr);
 }
 
+bool canConstCastFromTo(Expr const * from, Expr const * to) {
+    auto const k1 = from->getValueKind();
+    auto const k2 = to->getValueKind();
+    return (k2 == VK_LValue && k1 == VK_LValue)
+        || (k2 == VK_XValue
+            && (k1 != VK_RValue || from->getType()->isRecordType()));
+}
+
+char const * printExprValueKind(ExprValueKind k) {
+    switch (k) {
+    case VK_RValue:
+        return "prvalue";
+    case VK_LValue:
+        return "lvalue";
+    case VK_XValue:
+        return "xvalue";
+    };
+    llvm_unreachable("unknown ExprValueKind");
+}
+
 class RedundantCast:
     public RecursiveASTVisitor<RedundantCast>, public loplugin::RewritePlugin
 {
@@ -333,9 +353,46 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
     if (ignoreLocation(expr)) {
         return true;
     }
-    auto t1 = compat::getSubExprAsWritten(expr)->getType();
-    auto t2 = expr->getTypeAsWritten();
-    if (t1.getCanonicalType() != t2.getCanonicalType()) {
+    auto const sub = compat::getSubExprAsWritten(expr);
+    auto const t1 = sub->getType();
+    auto const t2 = expr->getTypeAsWritten();
+    auto const nonClassObjectType = t2->isObjectType()
+        && !(t2->isRecordType() || t2->isArrayType());
+    if (nonClassObjectType && t2.hasLocalQualifiers()) {
+        report(
+            DiagnosticsEngine::Warning,
+            ("in static_cast from %0 %1 to %2 %3, remove redundant top-level"
+             " %select{const qualifier|volatile qualifer|const volatile"
+             " qualifiers}4"),
+            expr->getExprLoc())
+            << t1 << printExprValueKind(sub->getValueKind())
+            << t2 << printExprValueKind(expr->getValueKind())
+            << ((t2.isLocalConstQualified() ? 1 : 0)
+                + (t2.isLocalVolatileQualified() ? 2 : 0) - 1)
+            << expr->getSourceRange();
+        return true;
+    }
+    auto const t3 = expr->getType();
+    auto const c1 = t1.getCanonicalType();
+    auto const c3 = t3.getCanonicalType();
+    if (nonClassObjectType || !canConstCastFromTo(sub, expr)
+        ? c1.getTypePtr() != c3.getTypePtr() : c1 != c3)
+    {
+        bool ObjCLifetimeConversion;
+        if (nonClassObjectType
+            || (c1.getTypePtr() != c3.getTypePtr()
+                && !compiler.getSema().IsQualificationConversion(
+                    c1, c3, false, ObjCLifetimeConversion)))
+        {
+            return true;
+        }
+        report(
+            DiagnosticsEngine::Warning,
+            "static_cast from %0 %1 to %2 %3 should be written as const_cast",
+            expr->getExprLoc())
+            << t1 << printExprValueKind(sub->getValueKind())
+            << t2 << printExprValueKind(expr->getValueKind())
+            << expr->getSourceRange();
         return true;
     }
     if (!isOkToRemoveArithmeticCast(t1, t2, expr->getSubExpr())) {
@@ -372,10 +429,21 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
             }
         }
     }
+    auto const k1 = sub->getValueKind();
+    auto const k3 = expr->getValueKind();
+    if ((k3 == VK_XValue && k1 != VK_XValue)
+        || (k3 == VK_LValue && k1 == VK_XValue))
+    {
+        return true;
+    }
     report(
         DiagnosticsEngine::Warning,
-        "redundant static_cast from %0 to %1", expr->getExprLoc())
-        << t1 << t2 << expr->getSourceRange();
+        ("static_cast from %0 %1 to %2 %3 is redundant%select{| or should be"
+         " written as an explicit construction of a temporary}4"),
+        expr->getExprLoc())
+        << t1 << printExprValueKind(k1) << t2 << printExprValueKind(k3)
+        << (k3 == VK_RValue && (k1 != VK_RValue || t1->isRecordType()))
+        << expr->getSourceRange();
     return true;
 }
 
diff --git a/compilerplugins/clang/salunicodeliteral.cxx b/compilerplugins/clang/salunicodeliteral.cxx
index 6b03156b55e7..410a1aba45c9 100644
--- a/compilerplugins/clang/salunicodeliteral.cxx
+++ b/compilerplugins/clang/salunicodeliteral.cxx
@@ -52,13 +52,23 @@ private:
 
     void check(ExplicitCastExpr const * expr) {
         if (ignoreLocation(expr)
-            || isInUnoIncludeFile(expr->getExprLoc())
+            || isInUnoIncludeFile(expr->getExprLoc()))
                 //TODO: '#ifdef LIBO_INTERNAL_ONLY' within UNO include files
-            || !(loplugin::TypeCheck(expr->getTypeAsWritten())
-                 .Typedef("sal_Unicode").GlobalNamespace()))
         {
             return;
         }
+        for (auto t = expr->getTypeAsWritten();;) {
+            auto const tt = t->getAs<TypedefType>();
+            if (tt == nullptr) {
+                return;
+            }
+            if (loplugin::TypeCheck(t).Typedef("sal_Unicode")
+                .GlobalNamespace())
+            {
+                break;
+            }
+            t = tt->desugar();
+        }
         auto const e1 = expr->getSubExprAsWritten();
         auto const loc = e1->getLocStart();
         if (loc.isMacroID()
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx
index b6754391e7ca..12fb26c826bf 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -7,18 +7,13 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include "redundantcast.hxx"
+
 void f1(char *) {}
 void f2(char const *) {}
 
 enum Enum1 { X };
 
-struct S {
-    void f1() { (void)*this; };
-    void f2() const { (void)*this; };
-    void f3() { (void)*this; }
-    void f3() const { (void)*this; };
-};
-
 int main() {
     char * p1;
     char const * p2;
@@ -45,6 +40,138 @@ int main() {
     const_cast<S &>(s).f2(); // expected-error {{redundant const_cast from 'const S' to 'S', result is implicitly cast to 'const S' [loplugin:redundantcast]}}
     const_cast<S &>(s).f3();
     s.f3();
+
+    // non-class lvalue, non-const:
+    int ni{};
+    (void) static_cast<int>(ni); // expected-error {{static_cast from 'int' lvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) int(ni); //TODO: expected-error {{redundant functional cast from/to 'int' [loplugin:redundantcast]}}
+    (void) static_cast<int &>(ni); // expected-error {{static_cast from 'int' lvalue to 'int &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<int &&>(ni);
+    (void) static_cast<int const>(ni); // expected-error {{in static_cast from 'int' lvalue to 'const int' prvalue, remove redundant top-level const qualifier [loplugin:redundantcast]}}
+    /* => */ (void) static_cast<int>(ni); // expected-error {{static_cast from 'int' lvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) int(ni); //TODO: expected-error {{redundant functional cast from/to 'int' [loplugin:redundantcast]}}
+    (void) static_cast<int const &>(ni); // expected-error {{static_cast from 'int' lvalue to 'const int &' lvalue should be written as const_cast [loplugin:redundantcast]}}
+    /* => */ (void) const_cast<int const &>(ni);
+    (void) static_cast<int const &&>(ni); // expected-error {{static_cast from 'int' lvalue to 'const int &&' xvalue should be written as const_cast [loplugin:redundantcast]}}
+    /* => */ (void) const_cast<int const &&>(ni);
+
+    // non-class lvalue, const:
+    int const ci{};
+    (void) static_cast<int>(ci); // expected-error {{static_cast from 'const int' lvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) int(ci);
+//  (void) static_cast<int &>(ci);
+//  (void) static_cast<int &&>(ci);
+    (void) static_cast<int const>(ci); // expected-error {{in static_cast from 'const int' lvalue to 'const int' prvalue, remove redundant top-level const qualifier [loplugin:redundantcast]}}
+    /* => */ (void) static_cast<int>(ci); // expected-error {{static_cast from 'const int' lvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) int(ci);
+    (void) static_cast<int const &>(ci); // expected-error {{static_cast from 'const int' lvalue to 'const int &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<int const &&>(ci);
+
+    // non-class xvalue, non-const:
+    (void) static_cast<int>(nix()); // expected-error {{static_cast from 'int' xvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) int(nix()); //TODO: expected-error {{redundant functional cast from/to 'int' [loplugin:redundantcast]}}
+//  (void) static_cast<int &>(nix());
+    (void) static_cast<int &&>(nix()); // expected-error {{static_cast from 'int' xvalue to 'int &&' xvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<int const>(nix()); // expected-error {{in static_cast from 'int' xvalue to 'const int' prvalue, remove redundant top-level const qualifier [loplugin:redundantcast]}}
+    /* => */ (void) static_cast<int>(nix()); // expected-error {{static_cast from 'int' xvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    (void) static_cast<int const &>(nix());
+    (void) static_cast<int const &&>(nix()); // expected-error {{static_cast from 'int' xvalue to 'const int &&' xvalue should be written as const_cast [loplugin:redundantcast]}}
+    /* => */ (void) const_cast<int const &&>(nix());
+
+    // non-class xvalue, const:
+    (void) static_cast<int>(cix()); // expected-error {{static_cast from 'const int' xvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) int(cix());
+//  (void) static_cast<int &>(cix());
+//  (void) static_cast<int &&>(cix());
+    (void) static_cast<int const>(cix()); // expected-error {{in static_cast from 'const int' xvalue to 'const int' prvalue, remove redundant top-level const qualifier [loplugin:redundantcast]}}
+    /* => */ (void) static_cast<int>(cix()); // expected-error {{static_cast from 'const int' xvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) int(cix());
+    (void) static_cast<int const &>(cix());
+    (void) static_cast<int const &&>(cix()); // expected-error {{static_cast from 'const int' xvalue to 'const int &&' xvalue is redundant [loplugin:redundantcast]}}
+
+    // non-class prvalue, non-const:
+    (void) static_cast<int>(nir()); // expected-error {{static_cast from 'int' prvalue to 'int' prvalue is redundant [loplugin:redundantcast]}}
+//  (void) static_cast<int &>(nir());
+    (void) static_cast<int &&>(nir());
+    (void) static_cast<int const>(nir()); // expected-error {{in static_cast from 'int' prvalue to 'const int' prvalue, remove redundant top-level const qualifier [loplugin:redundantcast]}}
+    /* => */ (void) static_cast<int>(nir()); // expected-error {{static_cast from 'int' prvalue to 'int' prvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<int const &>(nir()); // expected-error {{static_cast from 'int' prvalue to 'const int &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<int const &&>(nir());
+
+    // non-class prvalue, const:
+    (void) static_cast<int>(cir()); // expected-error {{static_cast from 'int' prvalue to 'int' prvalue is redundant [loplugin:redundantcast]}}
+//  (void) static_cast<int &>(cir());
+    (void) static_cast<int &&>(cir());
+    (void) static_cast<int const>(cir()); // expected-error {{in static_cast from 'int' prvalue to 'const int' prvalue, remove redundant top-level const qualifier [loplugin:redundantcast]}}
+    /* => */ (void) static_cast<int>(cir()); // expected-error {{static_cast from 'int' prvalue to 'int' prvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<int const &>(cir()); // expected-error {{static_cast from 'int' prvalue to 'const int &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<int const &&>(cir());
+
+    // class lvalue, non-const:
+    S ns{};
+    (void) static_cast<S>(ns); // expected-error {{static_cast from 'S' lvalue to 'S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) S(ns); //TODO: expected-error {{redundant functional cast from/to 'S' [loplugin:redundantcast]}}
+    (void) static_cast<S &>(ns); // expected-error {{static_cast from 'S' lvalue to 'S &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<S &&>(ns);
+    (void) static_cast<S const>(ns); // expected-error {{static_cast from 'S' lvalue to 'const S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ using CS = const S; (void) CS(ns);
+    (void) static_cast<S const &>(ns); // expected-error {{static_cast from 'S' lvalue to 'const S &' lvalue should be written as const_cast [loplugin:redundantcast]}}
+    /* => */ (void) const_cast<S const &>(ns);
+    (void) static_cast<S const &&>(ns); // expected-error {{static_cast from 'S' lvalue to 'const S &&' xvalue should be written as const_cast [loplugin:redundantcast]}}
+    /* => */ (void) const_cast<S const &&>(ns);
+
+    // class lvalue, const:
+    S const cs{};
+    (void) static_cast<S>(cs); // expected-error {{static_cast from 'const S' lvalue to 'S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) S(cs);
+//  (void) static_cast<S &>(cs);
+//  (void) static_cast<S &&>(cs);
+    (void) static_cast<S const>(cs); // expected-error {{static_cast from 'const S' lvalue to 'const S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) CS(cs);
+    (void) static_cast<S const &>(cs); // expected-error {{static_cast from 'const S' lvalue to 'const S &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<S const &&>(cs);
+
+    // class xvalue, non-const:
+    (void) static_cast<S>(nsx()); // expected-error {{static_cast from 'S' xvalue to 'S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) S(nsx()); //TODO: expected-error {{redundant functional cast from/to 'S' [loplugin:redundantcast]}}
+//  (void) static_cast<S &>(nsx());
+    (void) static_cast<S &&>(nsx()); // expected-error {{static_cast from 'S' xvalue to 'S &&' xvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<S const>(nsx()); // expected-error {{static_cast from 'S' xvalue to 'const S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) CS(nsx());
+    (void) static_cast<S const &>(nsx());
+    (void) static_cast<S const &&>(nsx()); // expected-error {{static_cast from 'S' xvalue to 'const S &&' xvalue should be written as const_cast [loplugin:redundantcast]}}
+    /* => */ (void) const_cast<S const &&>(nsx());
+
+    // class xvalue, const:
+    (void) static_cast<S>(csx()); // expected-error {{static_cast from 'const S' xvalue to 'S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) S(csx());
+//  (void) static_cast<S &>(csx());
+//  (void) static_cast<S &&>(csx());
+    (void) static_cast<S const>(csx()); // expected-error {{static_cast from 'const S' xvalue to 'const S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) CS(csx());
+    (void) static_cast<S const &>(csx());
+    (void) static_cast<S const &&>(csx()); // expected-error {{static_cast from 'const S' xvalue to 'const S &&' xvalue is redundant [loplugin:redundantcast]}}
+
+    // class prvalue, non-const:
+    (void) static_cast<S>(nsr()); // expected-error {{static_cast from 'S' prvalue to 'S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) S(nsr()); //TODO: expected-error {{redundant functional cast from/to 'S' [loplugin:redundantcast]}}
+//  (void) static_cast<S &>(nsr());
+    (void) static_cast<S &&>(nsr());
+    (void) static_cast<S const>(nsr()); // expected-error {{static_cast from 'S' prvalue to 'const S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) CS(nsr());
+    (void) static_cast<S const &>(nsr()); // expected-error {{static_cast from 'S' prvalue to 'const S &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<S const &&>(nsr()); // expected-error {{static_cast from 'S' prvalue to 'const S &&' xvalue should be written as const_cast [loplugin:redundantcast]}}
+    /* => */ (void) const_cast<S const &&>(nsr());
+
+    // class prvalue, const:
+    (void) static_cast<S>(csr()); // expected-error {{static_cast from 'const S' prvalue to 'S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) S(csr());
+//  (void) static_cast<S &>(csr());
+//  (void) static_cast<S &&>(csr());
+    (void) static_cast<S const>(csr()); // expected-error {{static_cast from 'const S' prvalue to 'const S' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}}
+    /* => */ (void) CS(csr());
+    (void) static_cast<S const &>(csr()); // expected-error {{static_cast from 'const S' prvalue to 'const S &' lvalue is redundant [loplugin:redundantcast]}}
+    (void) static_cast<S const &&>(csr());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/test/redundantcast.hxx b/compilerplugins/clang/test/redundantcast.hxx
new file mode 100644
index 000000000000..e87da7a55fe4
--- /dev/null
+++ b/compilerplugins/clang/test/redundantcast.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_COMPILERPLUGINS_CLANG_TEST_REDUNDANTCAST_HXX
+#define INCLUDED_COMPILERPLUGINS_CLANG_TEST_REDUNDANTCAST_HXX
+
+struct S {
+    void f1();
+    void f2() const;
+    void f3();
+    void f3() const;
+};
+
+int && nix();
+int const && cix();
+int nir();
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wignored-qualifiers"
+int const cir();
+#pragma clang diagnostic pop
+
+S && nsx();
+S const && csx();
+S nsr();
+S const csr();
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/test/salunicodeliteral.cxx b/compilerplugins/clang/test/salunicodeliteral.cxx
index 1daf9df0acb9..bf14e4843970 100644
--- a/compilerplugins/clang/test/salunicodeliteral.cxx
+++ b/compilerplugins/clang/test/salunicodeliteral.cxx
@@ -25,7 +25,8 @@ void f(sal_Unicode) {}
 void test() {
     f(sal_Unicode('x')); // expected-error {{in LIBO_INTERNAL_ONLY code, replace literal cast to 'sal_Unicode' (aka 'char16_t') with a u'...' char16_t character literal [loplugin:salunicodeliteral]}}
     f(static_cast<sal_Unicode>('x')); // expected-error {{in LIBO_INTERNAL_ONLY code, replace literal cast to 'sal_Unicode' (aka 'char16_t') with a u'...' char16_t character literal [loplugin:salunicodeliteral]}}
-    f(static_cast<sal_Unicode const>('x')); // expected-error {{in LIBO_INTERNAL_ONLY code, replace literal cast to 'const sal_Unicode' (aka 'const char16_t') with a u'...' char16_t character literal [loplugin:salunicodeliteral]}}
+    using T = sal_Unicode const;
+    f(static_cast<T>('x')); // expected-error {{in LIBO_INTERNAL_ONLY code, replace literal cast to 'T' (aka 'const char16_t') with a u'...' char16_t character literal [loplugin:salunicodeliteral]}}
     f((sal_Unicode) 'x'); // expected-error {{in LIBO_INTERNAL_ONLY code, replace literal cast to 'sal_Unicode' (aka 'char16_t') with a u'...' char16_t character literal [loplugin:salunicodeliteral]}}
     f(sal_Unicode(('x'))); // expected-error {{in LIBO_INTERNAL_ONLY code, replace literal cast to 'sal_Unicode' (aka 'char16_t') with a u'...' char16_t character literal [loplugin:salunicodeliteral]}}
     f(sal_Unicode(120)); // expected-error {{in LIBO_INTERNAL_ONLY code, replace literal cast to 'sal_Unicode' (aka 'char16_t') with a u'...' char16_t character literal [loplugin:salunicodeliteral]}}
commit 6a62339a6cc236cc39b827658099c3883fcffaa2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:56 2017 +0200

    Improved loplugin:redundantcast static_cast handling: cui
    
    Change-Id: I6c8ff3929201bdef23bc67fa82c73258f7a5437f

diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index bc1e6517b3a1..4ae7da1572bc 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1594,7 +1594,7 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
                 SfxModule* pScMod = SfxApplication::GetModule( SfxToolsModule::Calc );
                 setGroupName( "Calc", rCalcArray.GetString(0) );
                 nGroup = AddGroup( rCalcArray.GetString( 0 ), pScMod, pScMod, SID_SC_EDITOPTIONS );
-                const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rCalcArray.Count() );
+                const sal_uInt16 nCount = static_cast< sal_uInt16 >( rCalcArray.Count() );
                 for ( sal_uInt16 i = 1; i < nCount; ++i )
                 {
                     nPageId = (sal_uInt16)rCalcArray.GetValue(i);
@@ -1618,7 +1618,7 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
                 ResStringArray& rImpressArray = aDlgResource.GetImpressArray();
                 setGroupName( "Impress", rImpressArray.GetString(0) );
                 nGroup = AddGroup( rImpressArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_EDITOPTIONS );
-                const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rImpressArray.Count() );
+                const sal_uInt16 nCount = static_cast< sal_uInt16 >( rImpressArray.Count() );
                 for ( sal_uInt16 i = 1; i < nCount; ++i )
                 {
                     nPageId = (sal_uInt16)rImpressArray.GetValue(i);
@@ -1641,7 +1641,7 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
                 ResStringArray& rDrawArray = aDlgResource.GetDrawArray();
                 setGroupName( "Draw", rDrawArray.GetString(0) );
                 nGroup = AddGroup( rDrawArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS );
-                const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rDrawArray.Count() );
+                const sal_uInt16 nCount = static_cast< sal_uInt16 >( rDrawArray.Count() );
                 for ( sal_uInt16 i = 1; i < nCount; ++i )
                 {
                     nPageId = (sal_uInt16)rDrawArray.GetValue(i);
commit 7d81894613e8697f9291fb8c346b444cf024a786
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:50 2017 +0200

    Improved loplugin:redundantcast static_cast handling: dbaccess
    
    Change-Id: I4037cff3213f9885353ba0f5a810ceba68cb17b5

diff --git a/dbaccess/source/core/dataaccess/ContentHelper.cxx b/dbaccess/source/core/dataaccess/ContentHelper.cxx
index 20b25d46e05d..58b6bb46640e 100644
--- a/dbaccess/source/core/dataaccess/ContentHelper.cxx
+++ b/dbaccess/source/core/dataaccess/ContentHelper.cxx
@@ -537,8 +537,7 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent
         PropertiesEventListenerMap::const_iterator it = aListeners.begin();
         while ( !aListeners.empty() )
         {
-            XPropertiesChangeListener* pListener =
-                    static_cast< XPropertiesChangeListener * >( (*it).first );
+            XPropertiesChangeListener* pListener = (*it).first;
             PropertyEventSequence* pSeq = (*it).second;
 
             // Remove current element.
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 46f0fd82c972..c727bdb0bba5 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -730,7 +730,7 @@ bool SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm
                         if ( xSupplier.is() )
                             aInitialValues.push_back( NamedValue( "FormatsSupplier", makeAny( xSupplier ) ) );
                         aInitialValues.push_back( NamedValue( "TreatAsNumber", makeAny( bFormattedIsNumeric ) ) );
-                        aCopyProperties.push_back( static_cast<const OUString&>(PROPERTY_FORMATKEY) );
+                        aCopyProperties.push_back( PROPERTY_FORMATKEY );
                         break;
                 }
 
@@ -763,8 +763,8 @@ bool SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm
                     aInitialValues.push_back( NamedValue( sDefaultProperty, aDefault ) );
 
                 // transfer properties from the definition to the UNO-model :
-                aCopyProperties.push_back( static_cast<const OUString&>(PROPERTY_HIDDEN) );
-                aCopyProperties.push_back( static_cast<const OUString&>(PROPERTY_WIDTH) );
+                aCopyProperties.push_back( PROPERTY_HIDDEN );
+                aCopyProperties.push_back( PROPERTY_WIDTH );
 
                 // help text to display for the column
                 Any aDescription;
@@ -3343,8 +3343,8 @@ bool SbaTableQueryBrowser::ensureConnection( SvTreeListEntry* _pDSEntry, void* p
 
 IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData&, _rSortData, sal_Int32 )
 {
-    const SvTreeListEntry* pLHS = static_cast<const SvTreeListEntry*>(_rSortData.pLeft);
-    const SvTreeListEntry* pRHS = static_cast<const SvTreeListEntry*>(_rSortData.pRight);
+    const SvTreeListEntry* pLHS = _rSortData.pLeft;
+    const SvTreeListEntry* pRHS = _rSortData.pRight;
     OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
     // we want the table entry and the end so we have to do a check
 
diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx
index 9139bef7c531..c6b45907751f 100644
--- a/dbaccess/source/ui/dlg/tablespage.cxx
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -406,8 +406,8 @@ namespace dbaui
     }
     IMPL_LINK( OTableSubscriptionPage, OnTreeEntryCompare, const SvSortData&, _rSortData, sal_Int32 )
     {
-        const SvTreeListEntry* pLHS = static_cast<const SvTreeListEntry*>(_rSortData.pLeft);
-        const SvTreeListEntry* pRHS = static_cast<const SvTreeListEntry*>(_rSortData.pRight);
+        const SvTreeListEntry* pLHS = _rSortData.pLeft;
+        const SvTreeListEntry* pRHS = _rSortData.pRight;
         OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
 
         const SvLBoxString* pLeftTextItem = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SvLBoxItemType::String));
commit 7255c15cf5dd17701542c3769e948ffc089212d2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:44 2017 +0200

    Improved loplugin:redundantcast static_cast handling: drawinglayer
    
    Change-Id: I286b51f11410aad13bd4544998f0d6b56c854851

diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
index 0f70c0f20326..e9f67216869c 100644
--- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
@@ -295,7 +295,7 @@ namespace drawinglayer
 
         bool SvgGradientHelper::operator==(const SvgGradientHelper& rSvgGradientHelper) const
         {
-            const SvgGradientHelper& rCompare = static_cast< const SvgGradientHelper& >(rSvgGradientHelper);
+            const SvgGradientHelper& rCompare = rSvgGradientHelper;
 
             return (getGradientTransform() == rCompare.getGradientTransform()
                 && getPolyPolygon() == rCompare.getPolyPolygon()
commit 9b80567859754a49f23ae701ec59eb36820fd1a3
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:35 2017 +0200

    Improved loplugin:redundantcast static_cast handling: editeng
    
    Change-Id: Ia7541038df7c9eca00f99d70e5a1fc817028f686

diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index 96aac57b553d..6f93d8bf6280 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -310,8 +310,8 @@ bool EditRTFParser::IsEndPara( EditNodeIdx* pNd, sal_Int32 nCnt ) const
 
 void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
 {
-    ContentNode* pSttNode = const_cast<EditNodeIdx&>(static_cast<const EditNodeIdx&>(rSet.GetSttNode())).GetNode();
-    ContentNode* pEndNode = const_cast<EditNodeIdx&>(static_cast<const EditNodeIdx&>(rSet.GetEndNode())).GetNode();
+    ContentNode* pSttNode = const_cast<EditNodeIdx&>(rSet.GetSttNode()).GetNode();
+    ContentNode* pEndNode = const_cast<EditNodeIdx&>(rSet.GetEndNode()).GetNode();
 
     EditPaM aStartPaM( pSttNode, rSet.GetSttCnt() );
     EditPaM aEndPaM( pEndNode, rSet.GetEndCnt() );
diff --git a/include/editeng/txtrange.hxx b/include/editeng/txtrange.hxx
index db510d319b1b..3c857ad0e90f 100644
--- a/include/editeng/txtrange.hxx
+++ b/include/editeng/txtrange.hxx
@@ -75,7 +75,7 @@ public:
     bool IsInner() const { return bInner; }
     bool IsVertical() const { return bVertical; }
     const tools::Rectangle& GetBoundRect()
-        { return pBound ? static_cast< const tools::Rectangle& >(*pBound) : GetBoundRect_(); }
+        { return pBound ? const_cast< const tools::Rectangle& >(*pBound) : GetBoundRect_(); }
     void SetUpper( sal_uInt16 nNew ){ nUpper = nNew; }
     void SetLower( sal_uInt16 nNew ){ nLower = nNew; }
     void SetVertical( bool bNew );
commit 2b9556b3e44e5cbccfeea69cbace8bef255282f1
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:27 2017 +0200

    Improved loplugin:redundantcast static_cast handling: extensions
    
    Change-Id: I4320d9631977ed21245fc934368600c4c91668df

diff --git a/extensions/source/propctrlr/editpropertyhandler.cxx b/extensions/source/propctrlr/editpropertyhandler.cxx
index 073016ebda91..4d28814c1e81 100644
--- a/extensions/source/propctrlr/editpropertyhandler.cxx
+++ b/extensions/source/propctrlr/editpropertyhandler.cxx
@@ -232,13 +232,13 @@ namespace pcr
         std::vector< OUString > aSuperseded;
         if ( implHaveBothScrollBarProperties() )
         {
-            aSuperseded.push_back( static_cast<const OUString&>(PROPERTY_HSCROLL) );
-            aSuperseded.push_back( static_cast<const OUString&>(PROPERTY_VSCROLL) );
+            aSuperseded.push_back( PROPERTY_HSCROLL );
+            aSuperseded.push_back( PROPERTY_VSCROLL );
         }
         if ( implHaveTextTypeProperty() )
         {
-            aSuperseded.push_back(  static_cast<const OUString&>(PROPERTY_RICHTEXT) );
-            aSuperseded.push_back(  static_cast<const OUString&>(PROPERTY_MULTILINE) );
+            aSuperseded.push_back(  PROPERTY_RICHTEXT );
+            aSuperseded.push_back(  PROPERTY_MULTILINE );
         }
         if ( aSuperseded.empty() )
             return Sequence< OUString >();
@@ -251,8 +251,8 @@ namespace pcr
         ::osl::MutexGuard aGuard( m_aMutex );
         std::vector< OUString > aInterestingActuatingProps;
         if ( implHaveTextTypeProperty() )
-            aInterestingActuatingProps.push_back(  static_cast<const OUString&>(PROPERTY_TEXTTYPE) );
-        aInterestingActuatingProps.push_back( static_cast<const OUString&>(PROPERTY_MULTILINE) );
+            aInterestingActuatingProps.push_back(  PROPERTY_TEXTTYPE );
+        aInterestingActuatingProps.push_back( PROPERTY_MULTILINE );
         return Sequence< OUString >( &(*aInterestingActuatingProps.begin()), aInterestingActuatingProps.size() );
     }
 
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index 729fe7d9f3f4..c9dd53ef38a8 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -898,28 +898,28 @@ namespace pcr
     {
         ::osl::MutexGuard aGuard( m_aMutex );
         std::vector< OUString > aInterestingProperties;
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_DATASOURCE) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_COMMAND) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_COMMANDTYPE) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_LISTSOURCE) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_LISTSOURCETYPE) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_SUBMIT_ENCODING) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_REPEAT) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_TABSTOP) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_BORDER) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_CONTROLSOURCE) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_DROPDOWN) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_IMAGE_URL) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_TARGET_URL) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_STRINGITEMLIST) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_BUTTONTYPE) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_ESCAPE_PROCESSING) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_TRISTATE) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_DECIMAL_ACCURACY) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_SHOWTHOUSANDSEP) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_FORMATKEY) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_EMPTY_IS_NULL) );
-        aInterestingProperties.push_back(  static_cast<const OUString&>(PROPERTY_TOGGLE) );
+        aInterestingProperties.push_back(  PROPERTY_DATASOURCE );
+        aInterestingProperties.push_back(  PROPERTY_COMMAND );
+        aInterestingProperties.push_back(  PROPERTY_COMMANDTYPE );
+        aInterestingProperties.push_back(  PROPERTY_LISTSOURCE );
+        aInterestingProperties.push_back(  PROPERTY_LISTSOURCETYPE );
+        aInterestingProperties.push_back(  PROPERTY_SUBMIT_ENCODING );
+        aInterestingProperties.push_back(  PROPERTY_REPEAT );
+        aInterestingProperties.push_back(  PROPERTY_TABSTOP );
+        aInterestingProperties.push_back(  PROPERTY_BORDER );
+        aInterestingProperties.push_back(  PROPERTY_CONTROLSOURCE );
+        aInterestingProperties.push_back(  PROPERTY_DROPDOWN );
+        aInterestingProperties.push_back(  PROPERTY_IMAGE_URL );
+        aInterestingProperties.push_back(  PROPERTY_TARGET_URL );
+        aInterestingProperties.push_back(  PROPERTY_STRINGITEMLIST );
+        aInterestingProperties.push_back(  PROPERTY_BUTTONTYPE );
+        aInterestingProperties.push_back(  PROPERTY_ESCAPE_PROCESSING );
+        aInterestingProperties.push_back(  PROPERTY_TRISTATE );
+        aInterestingProperties.push_back(  PROPERTY_DECIMAL_ACCURACY );
+        aInterestingProperties.push_back(  PROPERTY_SHOWTHOUSANDSEP );
+        aInterestingProperties.push_back(  PROPERTY_FORMATKEY );
+        aInterestingProperties.push_back(  PROPERTY_EMPTY_IS_NULL );
+        aInterestingProperties.push_back(  PROPERTY_TOGGLE );
         return Sequence< OUString >( &(*aInterestingProperties.begin()), aInterestingProperties.size() );
     }
 
diff --git a/extensions/source/propctrlr/xsdvalidationhelper.cxx b/extensions/source/propctrlr/xsdvalidationhelper.cxx
index 6e43c5b3f122..77ed22992ab2 100644
--- a/extensions/source/propctrlr/xsdvalidationhelper.cxx
+++ b/extensions/source/propctrlr/xsdvalidationhelper.cxx
@@ -258,7 +258,7 @@ namespace pcr
                 Reference< XPropertySet > xNewType( getDataType( _rName ), UNO_QUERY );
 
                 // fire any changes in the properties which result from this new type
-                std::set< OUString > aFilter; aFilter.insert( static_cast<const OUString&>(PROPERTY_NAME) );
+                std::set< OUString > aFilter; aFilter.insert( PROPERTY_NAME );
                 firePropertyChanges( xOldType, xNewType, aFilter );
 
                 // fire the change in the Data Type property
commit 746de8119cb5824cfcbe195313e1de258d3b8d24
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:18 2017 +0200

    Improved loplugin:redundantcast static_cast handling: framework
    
    Change-Id: I3b4fa47a14a68edcdd3305787685531b0a760ab2

diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 28574963f084..8cc14fddf5ee 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -658,7 +658,7 @@ void LayoutManager::implts_writeWindowStateData( const OUString& aName, const UI
             aWindowState[1].Value <<= rElementData.m_bVisible;
 
             aWindowState[2].Name  = WINDOWSTATE_PROPERTY_DOCKINGAREA;
-            aWindowState[2].Value <<= static_cast< DockingArea >( rElementData.m_aDockedData.m_nDockedArea );
+            aWindowState[2].Value <<= rElementData.m_aDockedData.m_nDockedArea;
 
             aWindowState[3].Name = WINDOWSTATE_PROPERTY_DOCKPOS;
             aWindowState[3].Value <<= rElementData.m_aDockedData.m_aPos;
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index 9ef5503210fa..6d6521efd06f 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -1594,7 +1594,7 @@ void ToolbarLayoutManager::implts_writeWindowStateData( const UIElement& rElemen
             aWindowState[1].Name  = WINDOWSTATE_PROPERTY_VISIBLE;
             aWindowState[1].Value <<= rElementData.m_bVisible;
             aWindowState[2].Name  = WINDOWSTATE_PROPERTY_DOCKINGAREA;
-            aWindowState[2].Value <<= static_cast< ui::DockingArea >( rElementData.m_aDockedData.m_nDockedArea );
+            aWindowState[2].Value <<= rElementData.m_aDockedData.m_nDockedArea;
 
             awt::Point aPos = rElementData.m_aDockedData.m_aPos;
             aWindowState[3].Name  = WINDOWSTATE_PROPERTY_DOCKPOS;
commit fbf8fa7e4728a717039b8779d69321cb88e5e527
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:11 2017 +0200

    Improved loplugin:redundantcast static_cast handling: opencl
    
    Change-Id: I45fc65e3b27e0c57d041c4f724c23d90ec1448d3

diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index 2ca0a603a5da..d59630c53981 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -768,13 +768,13 @@ void findDeviceInfoFromDeviceId(cl_device_id aDeviceId, size_t& rDeviceId, size_
     const std::vector<OpenCLPlatformInfo>& rPlatforms = fillOpenCLInfo();
     for(size_t i = 0; i < rPlatforms.size(); ++i)
     {
-        cl_platform_id platId = static_cast<cl_platform_id>(rPlatforms[i].platform);
+        cl_platform_id platId = rPlatforms[i].platform;
         if(platId != platformId)
             continue;
 
         for(size_t j = 0; j < rPlatforms[i].maDevices.size(); ++j)
         {
-            cl_device_id id = static_cast<cl_device_id>(rPlatforms[i].maDevices[j].device);
+            cl_device_id id = rPlatforms[i].maDevices[j].device;
             if(id == aDeviceId)
             {
                 rDeviceId = j;
commit cac4aa7b7a272e81360bcd27a6388500b0f6aeef
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:37:06 2017 +0200

    Improved loplugin:redundantcast static_cast handling: package
    
    Change-Id: I3b38df7b130ac8c0591b9429d871274718dcb993

diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 03884d510b38..01f2896d68f0 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -1226,7 +1226,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName,
                 sal_Int8 *pArray = aSequence.getArray();
                 const sal_Unicode *pChar = sTempString.getStr();
                 for ( sal_Int32 i = 0; i < nPathLength; i++ )
-                    pArray[i] = static_cast < const sal_Int8 > ( pChar[i] );
+                    pArray[i] = static_cast < sal_Int8 > ( pChar[i] );
                 aNewKey = aSequence;
             }
             else
commit c71d9f3bb1aad3f86de93655cf02313a8894f877
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:56 2017 +0200

    Improved loplugin:redundantcast static_cast handling: reportdesign
    
    Change-Id: Ifd1c46b077df5b73e3fcba699e8d598e38664840

diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index 7aa1e7dc8974..25e514552b10 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -1159,15 +1159,15 @@ void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormatted
             if ( !aPos.X )
             {
                 sBorderProp = PROPERTY_BORDERLEFT;
-                aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERRIGHT));
+                aProps.push_back(PROPERTY_BORDERRIGHT);
             }
             else
             {
                 sBorderProp = PROPERTY_BORDERRIGHT;
-                aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERLEFT));
+                aProps.push_back(PROPERTY_BORDERLEFT);
             }
-            aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERTOP));
-            aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERBOTTOM));
+            aProps.push_back(PROPERTY_BORDERTOP);
+            aProps.push_back(PROPERTY_BORDERBOTTOM);
         }
         else // horizontal
         {
@@ -1175,15 +1175,15 @@ void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormatted
             if ( (aPos.Y + aSize.Height) == nSectionHeight )
             {
                 sBorderProp = PROPERTY_BORDERBOTTOM;
-                aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERTOP));
+                aProps.push_back(PROPERTY_BORDERTOP);
             }
             else
             {
                 sBorderProp = PROPERTY_BORDERTOP;
-                aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERBOTTOM));
+                aProps.push_back(PROPERTY_BORDERBOTTOM);
             }
-            aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERRIGHT));
-            aProps.push_back(static_cast<const OUString&>(PROPERTY_BORDERLEFT));
+            aProps.push_back(PROPERTY_BORDERRIGHT);
+            aProps.push_back(PROPERTY_BORDERLEFT);
         }
 
         xBorderProp->setPropertyValue(sBorderProp,uno::makeAny(aValue));
commit c72d788410c13321c7079b2f185a26baea735b59
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:49 2017 +0200

    Improved loplugin:redundantcast static_cast handling: sc
    
    Change-Id: I11f0deb6913a7a3adc6bc31890451e05bfa00802

diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 8bbad1cb6e60..63b1279cd266 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1274,7 +1274,7 @@ void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, co
 {
     SCCOL nBCol( rValBaseAddr.Col() );
     SCROW nBRow( rValBaseAddr.Row() );
-    SCTAB nTab( static_cast<const sal_Int32>(rValBaseAddr.Tab()) );
+    SCTAB nTab( static_cast<sal_Int32>(rValBaseAddr.Tab()) );
     //get from the document the data validation entry we are checking against
     const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>(rDoc.GetAttr(nBCol, nBRow, nTab, ATTR_VALIDDATA) );
     const ScValidationData* pValData = rDoc.GetValidationEntry( pItem->GetValue() );
@@ -1290,12 +1290,12 @@ void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, co
             //prevent string operations for occurring unnecessarily
             if(!(pValDataTest && pValData->GetKey() == pValDataTest->GetKey()))
             {
-                sal_Int32 nCol = static_cast<const sal_Int32>(i);
-                sal_Int32 nRow = static_cast<const sal_Int32>(j);
-                sal_Int32 nTab32 = static_cast<const sal_Int32>(nTab);
+                sal_Int32 nCol = static_cast<sal_Int32>(i);
+                sal_Int32 nRow = static_cast<sal_Int32>(j);
+                sal_Int32 nTab32 = static_cast<sal_Int32>(nTab);
                 OStringBuffer sMsg("\nData validation entry base-cell-address: (");
-                sMsg.append( static_cast<const sal_Int32>(nBCol) ).append(",");
-                sMsg.append( static_cast<const sal_Int32>(nBRow) ).append(",");
+                sMsg.append( static_cast<sal_Int32>(nBCol) ).append(",");
+                sMsg.append( static_cast<sal_Int32>(nBRow) ).append(",");
                 sMsg.append( nTab32 ).append(")\n");
                 sMsg.append("Cell: (").append(nCol).append(",").append(nRow).append(",").append(nTab32).append(")");
                 sal_uInt32 expectedKey(pValData->GetKey());
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 94d04e2f433f..1948add201cd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2708,7 +2708,7 @@ void Test::testGraphicsInGroup()
         pPage->InsertObject(pObj);
         const tools::Rectangle &rNewRect = pObj->GetLogicRect();
         CPPUNIT_ASSERT_EQUAL_MESSAGE("must have equal position and size",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         ScDrawLayer::SetPageAnchored(*pObj);
 
@@ -2716,15 +2716,15 @@ void Test::testGraphicsInGroup()
         m_pDoc->ShowRows(0, 100, 0, false);
         m_pDoc->SetDrawPageSize(0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Should not change when page anchored",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
         m_pDoc->ShowRows(0, 100, 0, true);
         m_pDoc->SetDrawPageSize(0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Should not change when page anchored",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("That shouldn't change size or positioning",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         m_pDoc->ShowRows(0, 100, 0, false);
         m_pDoc->SetDrawPageSize(0);
@@ -2735,7 +2735,7 @@ void Test::testGraphicsInGroup()
         m_pDoc->ShowRows(0, 100, 0, true);
         m_pDoc->SetDrawPageSize(0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Should not change when page anchored",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
     }
 
     {
@@ -2745,11 +2745,11 @@ void Test::testGraphicsInGroup()
         pPage->InsertObject(pObj);
         const tools::Rectangle& rNewRect = pObj->GetLogicRect();
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Position and size of the circle shouldn't change when inserted into the page.",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Size changed when cell anchored. Not good.",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         // Insert 2 rows at the top.  This should push the circle object down.
         m_pDoc->InsertRow(0, 0, MAXCOL, 0, 0, 2);
@@ -2763,7 +2763,7 @@ void Test::testGraphicsInGroup()
         m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 0, 2);
         m_pDoc->SetDrawPageSize(0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to move back to its original position.",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
     }
 
     {
@@ -2778,18 +2778,18 @@ void Test::testGraphicsInGroup()
         pPage->InsertObject(pObj);
         const tools::Rectangle& rNewRect = pObj->GetLogicRect();
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Size differ.",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Size changed when cell-anchored. Not good.",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         // Insert 2 rows at the top and delete them immediately.
         m_pDoc->InsertRow(0, 0, MAXCOL, 0, 0, 2);
         m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 0, 2);
         m_pDoc->SetDrawPageSize(0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Size of a line object changed after row insertion and removal.",
-                               static_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
+                               const_cast<const tools::Rectangle &>(aOrigRect), rNewRect);
 
         sal_Int32 n = pObj->GetPointCount();
         CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly 2 points in a line object.", static_cast<sal_Int32>(2), n);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index d436b2b0aff8..d4a85cd6cd8a 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -134,7 +134,7 @@ void Test::testCondFormatInsertCol()
 
     m_pDoc->InsertCol(0,0,MAXROW,0,4,2);
     const ScRangeList& rRange = pFormat->GetRange();
-    CPPUNIT_ASSERT_EQUAL(static_cast<const ScRangeList&>(ScRangeList(ScRange(0,0,0,5,3,0))), rRange);
+    CPPUNIT_ASSERT_EQUAL(ScRangeList(ScRange(0,0,0,5,3,0)), rRange);
 
     m_pDoc->DeleteTab(0);
 }
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index 376a22681259..ffa726a7c27a 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -253,9 +253,9 @@ bool ScTpFormulaOptions::FillItemSet(SfxItemSet* rCoreSet)
 
     if ( mpLbFormulaSyntax->GetSavedValue() != aSyntaxPos
          || mpCbEnglishFuncName->GetSavedValue() != (bEnglishFuncName ? 1 : 0)
-         || static_cast<OUString>(mpEdSepFuncArg->GetSavedValue()) != aSep
-         || static_cast<OUString>(mpEdSepArrayCol->GetSavedValue()) != aSepArrayCol
-         || static_cast<OUString>(mpEdSepArrayRow->GetSavedValue()) != aSepArrayRow
+         || mpEdSepFuncArg->GetSavedValue() != aSep
+         || mpEdSepArrayCol->GetSavedValue() != aSepArrayCol
+         || mpEdSepArrayRow->GetSavedValue() != aSepArrayRow
          || mpLbOOXMLRecalcOptions->GetSavedValue() != nOOXMLRecalcMode
          || mpLbODFRecalcOptions->GetSavedValue() != nODFRecalcMode
          || maSavedConfig != maCurrentConfig
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index bee5f1501dd7..a75efc3e9f71 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -377,7 +377,7 @@ SvxNumberInfoItem* ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc, ScViewD
     }
 
     return new SvxNumberInfoItem(
-        pDoc->GetFormatTable(), static_cast<const sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO));
+        pDoc->GetFormatTable(), static_cast<sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO));
 }
 
 void ScTabViewShell::UpdateNumberFormatter(
commit b38b619681465459e0330b9a3417fffcc4e15a17
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:44 2017 +0200

    Improved loplugin:redundantcast static_cast handling: sd
    
    Change-Id: I07297ff8ceb69c0da2396b452bb7448f8c4ca07b

diff --git a/sd/source/ui/unoidl/DrawController.cxx b/sd/source/ui/unoidl/DrawController.cxx
index 451b239b24b9..cc2e3e427021 100644
--- a/sd/source/ui/unoidl/DrawController.cxx
+++ b/sd/source/ui/unoidl/DrawController.cxx
@@ -62,10 +62,7 @@ namespace sd {
 DrawController::DrawController (ViewShellBase& rBase) throw()
     : DrawControllerInterfaceBase(&rBase),
       BroadcastHelperOwner(SfxBaseController::m_aMutex),
-      OPropertySetHelper( static_cast<OBroadcastHelperVar<
-          OMultiTypeInterfaceContainerHelper,
-          OMultiTypeInterfaceContainerHelper::keyType>& >(
-              BroadcastHelperOwner::maBroadcastHelper)),
+      OPropertySetHelper(BroadcastHelperOwner::maBroadcastHelper),
       m_aSelectionTypeIdentifier(
         cppu::UnoType<view::XSelectionChangeListener>::get()),
       mpBase(&rBase),
commit a760d2d1d05e04085e66c30eaf4ac23a4a1faf51
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:38 2017 +0200

    Improved loplugin:redundantcast static_cast handling: stoc
    
    Change-Id: I30b0c1a3f07d55f5f024fb2a595592eb0417ad9a

diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx
index 6772d2ba2a8a..cbeb631d2be8 100644
--- a/stoc/source/security/access_controller.cxx
+++ b/stoc/source/security/access_controller.cxx
@@ -249,12 +249,12 @@ inline Reference< security::XAccessControlContext > getDynamicRestriction(
             if ( typeName == "com.sun.star.security.XAccessControlContext" )
             {
                 return Reference< security::XAccessControlContext >(
-                    *static_cast< security::XAccessControlContext ** const >( acc.pData ) );
+                    *static_cast< security::XAccessControlContext ** >( acc.pData ) );
             }
             else // try to query
             {
                 return Reference< security::XAccessControlContext >::query(
-                    *static_cast< XInterface ** const >( acc.pData ) );
+                    *static_cast< XInterface ** >( acc.pData ) );
             }
         }
     }
commit da76bb4f2ad68e36aaad1b6e451b53388141c845
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:33 2017 +0200

    Improved loplugin:redundantcast static_cast handling: svx
    
    Change-Id: I299d53fcef4276626944cfbaefbf1bbd4ce5d5ab

diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index cbf4db08f645..e970442823d1 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1208,7 +1208,7 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I
     if(nDecimalMark > nNumDigits)
     {
         const sal_Int32 nDiff(nDecimalMark - nNumDigits);
-        const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
+        const double fFactor(pow(10.0, static_cast<int>(nDiff)));
 
         fLocalValue /= fFactor;
         nDecimalMark = nNumDigits;
@@ -1216,7 +1216,7 @@ void SdrModel::TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars, sal_I
     else if(nDecimalMark < nNumDigits)
     {
         const sal_Int32 nDiff(nNumDigits - nDecimalMark);
-        const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
+        const double fFactor(pow(10.0, static_cast<int>(nDiff)));
 
         fLocalValue *= fFactor;
         nDecimalMark = nNumDigits;
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 2206b8bb8a36..772afa3d0f5b 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1471,7 +1471,7 @@ SdrOle2Obj& SdrOle2Obj::assignFrom(const SdrOle2Obj& rObj)
     if( &rObj != this )
     {
         // ImpAssign( rObj );
-        const SdrOle2Obj& rOle2Obj = static_cast< const SdrOle2Obj& >( rObj );
+        const SdrOle2Obj& rOle2Obj = rObj;
 
         if( pModel && mpImpl->mbConnected )
             Disconnect();
commit f51dc77f30b0b38122b498f02d19045b6b224921
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:29 2017 +0200

    Improved loplugin:redundantcast static_cast handling: sw
    
    Change-Id: I699e7f0201d6c49344cfeb5a1146b20fcde72f9b

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 4b3daa8bcee2..d5e5cb40cf4e 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1082,7 +1082,7 @@ const SwNode& SwCompareLine::GetEndNode() const
 
 bool SwCompareLine::Compare( const SwCompareLine& rLine ) const
 {
-    return CompareNode( rNode, static_cast<const SwCompareLine&>(rLine).rNode );
+    return CompareNode( rNode, rLine.rNode );
 }
 
 namespace
diff --git a/sw/source/core/text/frminf.cxx b/sw/source/core/text/frminf.cxx
index a4f6c1a4ec86..ed500ceafed6 100644
--- a/sw/source/core/text/frminf.cxx
+++ b/sw/source/core/text/frminf.cxx
@@ -115,7 +115,7 @@ SwTwips SwTextFrameInfo::GetCharPos( sal_Int32 nChar, bool bCenter ) const
 
     SwTwips nStt, nNext;
     SwRect aRect;
-    if( static_cast<SwTextCursor&>(aLine).GetCharRect( &aRect, nChar ) )
+    if( aLine.GetCharRect( &aRect, nChar ) )
     {
         if ( aRectFnSet.IsVert() )
             pFrame->SwitchHorizontalToVertical( aRect );
@@ -128,7 +128,7 @@ SwTwips SwTextFrameInfo::GetCharPos( sal_Int32 nChar, bool bCenter ) const
     if( !bCenter )
         return nStt - aRectFnSet.GetLeft(pFrame->Frame());
 
-    if( static_cast<SwTextCursor&>(aLine).GetCharRect( &aRect, nChar+1 ) )
+    if( aLine.GetCharRect( &aRect, nChar+1 ) )
     {
         if ( aRectFnSet.IsVert() )
             pFrame->SwitchHorizontalToVertical( aRect );
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 4762a1950faa..d329543cb453 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -798,7 +798,7 @@ SwFootnotePortion *SwTextFormatter::NewFootnotePortion( SwTextFormatInfo &rInf,
         return nullptr;
 
     SwTextFootnote  *pFootnote = static_cast<SwTextFootnote*>(pHint);
-    const SwFormatFootnote& rFootnote = static_cast<const SwFormatFootnote&>(pFootnote->GetFootnote());
+    const SwFormatFootnote& rFootnote = pFootnote->GetFootnote();
     SwDoc *pDoc = m_pFrame->GetNode()->GetDoc();
 
     if( rInf.IsTest() )
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 2ae3720dd6ae..e7e91f37ad7e 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1552,8 +1552,8 @@ void lcl_CopyHint(
             {
                 pFormat = pOtherDoc->CopyCharFormat( *pFormat );
             }
-            const_cast<SwFormatCharFormat&>( static_cast<const SwFormatCharFormat&>(
-                pNewHt->GetCharFormat() ) ).SetCharFormat( pFormat );
+            const_cast<SwFormatCharFormat&>(
+                pNewHt->GetCharFormat() ).SetCharFormat( pFormat );
         }
         break;
     case RES_TXTATR_INETFMT :
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 1ac8829b1bf9..3087aec171f2 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -522,12 +522,12 @@ void SwHistoryChangeFormatColl::SetInDoc( SwDoc* pDoc, bool )
     {
         if ( SwNodeType::Text == m_nNodeType )
         {
-            if (pDoc->GetTextFormatColls()->IsAlive(static_cast<SwTextFormatColl * const>(m_pColl)))
+            if (pDoc->GetTextFormatColls()->IsAlive(static_cast<SwTextFormatColl *>(m_pColl)))
             {
                 pContentNd->ChgFormatColl( m_pColl );
             }
         }
-        else if (pDoc->GetGrfFormatColls()->IsAlive(static_cast<SwGrfFormatColl * const>(m_pColl)))
+        else if (pDoc->GetGrfFormatColls()->IsAlive(static_cast<SwGrfFormatColl *>(m_pColl)))
         {
             pContentNd->ChgFormatColl( m_pColl );
         }
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index de6d41b9822c..2f9cd4f49b87 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -469,7 +469,7 @@ void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext)
         if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() ))
         {
             SwRangeRedline* pTmp = new SwRangeRedline(*pRedlData, rPam);
-            static_cast<SwRedlineTable&>(rDoc.getIDocumentRedlineAccess().GetRedlineTable()).Insert( pTmp );
+            rDoc.getIDocumentRedlineAccess().GetRedlineTable().Insert( pTmp );
             pTmp->InvalidateRange();
         }
         else if( !( RedlineFlags::Ignore & GetRedlineFlags() ) &&
@@ -495,7 +495,7 @@ void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext)
         SwPaM& rPam(AddUndoRedoPaM(rContext));
 
         SwRangeRedline* pTmp = new SwRangeRedline(*pRedlData, rPam);
-        static_cast<SwRedlineTable&>(rDoc.getIDocumentRedlineAccess().GetRedlineTable()).Insert( pTmp );
+        rDoc.getIDocumentRedlineAccess().GetRedlineTable().Insert( pTmp );
         pTmp->InvalidateRange();
 
         SetPaM(rPam, true);
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 2f4520b6e8c3..dc214b0e3938 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -413,7 +413,7 @@ lcl_FillFieldMarkArray(FieldMarks_t & rFieldMarks, SwUnoCursor const & rUnoCurso
 
     const sal_Unicode fld[] = {
         CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND, CH_TXT_ATR_FORMELEMENT, 0 };
-    sal_Int32 pos = std::max(static_cast<const sal_Int32>(0), i_nStartPos);
+    sal_Int32 pos = std::max(static_cast<sal_Int32>(0), i_nStartPos);
     while ((pos = ::comphelper::string::indexOfAny(pTextNode->GetText(), fld, pos)) != -1)
     {
         rFieldMarks.push_back(pos);
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 79fa4fcd7924..2860a4a250e6 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4919,10 +4919,10 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
             CharHighlight( static_cast< const SvxBrushItem& >( rHt ) );
             break;
         case RES_CHRATR_BIDIRTL:
-            CharBidiRTL( static_cast< const SfxPoolItem& >( rHt ) );
+            CharBidiRTL( rHt );
             break;
         case RES_CHRATR_IDCTHINT:
-            CharIdctHint( static_cast< const SfxPoolItem& >( rHt ) );
+            CharIdctHint( rHt );
             break;
         case RES_TXTATR_INETFMT:
             TextINetFormat( static_cast< const SwFormatINetFormat& >( rHt ) );
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index 29e6199534ce..2c8d69346959 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -702,8 +702,8 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet)
         case SID_FLIP_HORIZONTAL:
             if( !bParentCntProt )
             {
-                MirrorGraph nState = static_cast< const MirrorGraph >(static_cast<const SwMirrorGrf &>( aCoreSet.Get(
-                                        RES_GRFATR_MIRRORGRF )).GetValue());
+                MirrorGraph nState = static_cast<const SwMirrorGrf &>( aCoreSet.Get(
+                                        RES_GRFATR_MIRRORGRF )).GetValue();
 
                 rSet.Put(SfxBoolItem( nWhich, nState == MirrorGraph::Vertical ||
                                               nState == MirrorGraph::Both));
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 2eb1d6d10c49..f049202a95d2 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -394,7 +394,7 @@ void ItemSetToTableParam( const SfxItemSet& rSet,
         // The item must only be recorded while manual alignment, so that the
         // alignment is not overwritten by the distances while recording.
         if(eOrient != text::HoriOrientation::NONE)
-            const_cast<SfxItemSet&>(static_cast<const SfxItemSet&>(rSet)).ClearItem( SID_ATTR_LRSPACE );
+            const_cast<SfxItemSet&>(rSet).ClearItem( SID_ATTR_LRSPACE );
 
         if(pRep->HasColsChanged())
         {
diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx
index bd91fef1db4e..57539a56b6e7 100644
--- a/sw/source/uibase/sidebar/ThemePanel.cxx
+++ b/sw/source/uibase/sidebar/ThemePanel.cxx
@@ -204,7 +204,7 @@ void changeFont(SwFormat* pFormat, SwDocStyleSheet* pStyle, FontSet& rFontSet)
         return;
     }
 
-    SvxFontItem aFontItem(static_cast<const SvxFontItem&>(pFormat->GetFont(false)));
+    SvxFontItem aFontItem(pFormat->GetFont(false));
 
     FontPitch ePitch = aFontItem.GetPitch();
 
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 38f1dd1f75fa..3f4758540ab6 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -792,7 +792,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
     }
     else
     {
-        SwDoc& rDoc = *static_cast<SwDocShell&>(rDocSh).GetDoc();
+        SwDoc& rDoc = *rDocSh.GetDoc();
 
         if( !bOldShellWasSrcView && bWebDShell && !m_bOldShellWasPagePreview )
             aUsrPref.setBrowseMode( true );
commit 04f6481e4edf160d8d01817c770b56a5abeb7702
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:25 2017 +0200

    Improved loplugin:redundantcast static_cast handling: unoidl
    
    Change-Id: Ic959703c5f5ff594d0c430f6756a3fadf09cfd73

diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index 0488efa987cf..55095d9ec6bd 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -41,7 +41,7 @@ ConstantValue translateConstantValue(
 {
     switch (value.m_type) {
     case RT_TYPE_BOOL:
-        return ConstantValue(static_cast< bool >(value.m_value.aBool));
+        return ConstantValue(value.m_value.aBool);
     case RT_TYPE_BYTE:
         return ConstantValue(value.m_value.aByte);
     case RT_TYPE_INT16:
commit cc6451efd98eff04935e8da5e05dd26a6b208557
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 09:36:18 2017 +0200

    Improved loplugin:redundantcast static_cast handling: vcl
    
    Change-Id: I3cf2f05b0076c6c99b84eef4246d3d5c149d6f3d

diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index bf039f142d58..d76d787f173e 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -1613,7 +1613,7 @@ long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_b
     long nIndex = i_nStartIndex;
     if( nIndex < i_nW )
     {
-        const sal_uInt8 * pByte = static_cast<sal_uInt8*>(i_pLine) + (nIndex/8);
+        const sal_uInt8 * pByte = i_pLine + (nIndex/8);
         sal_uInt8 nByte = *pByte;
 
         // run up to byte boundary


More information about the Libreoffice-commits mailing list