From 7d858ad0575b8be58dfb69773e2fba2cf95409c8 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 30 May 2017 15:46:55 +0200 Subject: Restrict loplugin:redundantcast to "real" casts Change-Id: Ifc9de898e5c9a084cbfd739625c679185c3a1534 --- compilerplugins/clang/redundantcast.cxx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 4ffef355bd6a..8b5eb3d90e91 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -480,17 +480,20 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp return true; if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/svl/qa/")) return true; - // the array-of-struct initialiser here makes clang unhappy if I remove all of the "SchemeInfo" names - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/tools/source/fsys/urlobj.cxx")) - return true; - // 2 structs with compiled-generated constructors where I cannot remove the cast even though the cast is a NoOp - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/tools/source/inet/inetmime.cxx")) - return true; - // some explicit use of std::initializer_list - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/svx/source/sidebar/area/AreaPropertyPanel.cxx")) - return true; - if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/svx/source/tbxctrls/fillctrl.cxx")) + + // Restrict this to "real" casts (compared to uses of braced-init-list, like + // + // Foo{bar, baz} + // + // or + // + // std::initializer_list{bar, baz} + // + // ), at least for now: + auto const sub = compat::getSubExprAsWritten(expr); + if (isa(sub) || isa(sub)) { return true; + } // See the commit message of d0e7d020fa405ab94f19916ec96fbd4611da0031 // "socket.c -> socket.cxx" for the reason to have @@ -498,7 +501,6 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp // bool(FD_ISSET(...)) // // in sal/osl/unx/socket.cxx: - auto const sub = compat::getSubExprAsWritten(expr); //TODO: Better check that sub is exactly an expansion of FD_ISSET: if (sub->getLocEnd().isMacroID()) { for (auto loc = sub->getLocStart(); -- cgit