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

Stephan Bergmann sbergman at redhat.com
Fri Jun 2 08:36:08 UTC 2017


 compilerplugins/clang/redundantcast.cxx      |    4 ++--
 compilerplugins/clang/test/redundantcast.cxx |   12 ++++++------
 compilerplugins/clang/test/stringcopy.cxx    |    2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 1fce9840512f15430bf98004269527f83cd3f0f8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 2 10:35:05 2017 +0200

    Make loplugin:redundantcast functional cast warnings more verbose
    
    (useful when types involve typedefs)
    
    Change-Id: I93e8962fd4b9c4ef79990e057dfa07538380008c

diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index 93fb8a880ad4..6bc97e5351a3 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -581,8 +581,8 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp
         return true;
     report(
         DiagnosticsEngine::Warning,
-        "redundant functional cast from/to %0", expr->getExprLoc())
-        << t1 << expr->getSourceRange();
+        "redundant functional cast from %0 to %1", expr->getExprLoc())
+        << t2 << t1 << expr->getSourceRange();
     return true;
 }
 
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx
index 12fb26c826bf..ddf525ae9f0c 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -44,12 +44,12 @@ int main() {
     // 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) int(ni); //TODO: expected-error {{redundant functional cast from 'int' 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) int(ni); //TODO: expected-error {{redundant functional cast from 'int' 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]}}
@@ -69,7 +69,7 @@ int main() {
 
     // 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) int(nix()); //TODO: expected-error {{redundant functional cast from 'int' 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]}}
@@ -110,7 +110,7 @@ int main() {
     // 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) S(ns); //TODO: expected-error {{redundant functional cast from 'S' 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]}}
@@ -133,7 +133,7 @@ int main() {
 
     // 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) S(nsx()); //TODO: expected-error {{redundant functional cast from 'S' 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]}}
@@ -154,7 +154,7 @@ int main() {
 
     // 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) S(nsr()); //TODO: expected-error {{redundant functional cast from 'S' 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]}}
diff --git a/compilerplugins/clang/test/stringcopy.cxx b/compilerplugins/clang/test/stringcopy.cxx
index f571f914b20e..01d10ceef833 100644
--- a/compilerplugins/clang/test/stringcopy.cxx
+++ b/compilerplugins/clang/test/stringcopy.cxx
@@ -13,7 +13,7 @@
 
 int main() {
     OUString s;
-    (void) OUString(s); // expected-error {{redundant copy construction from 'rtl::OUString' to 'rtl::OUString' [loplugin:stringcopy]}} expected-error {{redundant functional cast from/to 'rtl::OUString' [loplugin:redundantcast]}}
+    (void) OUString(s); // expected-error {{redundant copy construction from 'rtl::OUString' to 'rtl::OUString' [loplugin:stringcopy]}} expected-error {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantcast]}}
     using T1 = OUString;
     (void) T1(s); // expected-error {{redundant copy construction from 'rtl::OUString' to 'T1' (aka 'rtl::OUString') [loplugin:stringcopy]}}
     using T2 = OUString const;


More information about the Libreoffice-commits mailing list