summaryrefslogtreecommitdiffstats
path: root/compilerplugins/clang/redundantcast.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-05-30 15:46:55 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-05-30 15:46:55 +0200
commit7d858ad0575b8be58dfb69773e2fba2cf95409c8 (patch)
treea1e294ae3c70307c80d4324cbecd353bf738e50f /compilerplugins/clang/redundantcast.cxx
parenttdf#105566: Add/remove infobar when the signature status changes (diff)
downloadcore-7d858ad0575b8be58dfb69773e2fba2cf95409c8.tar.gz
core-7d858ad0575b8be58dfb69773e2fba2cf95409c8.zip
Restrict loplugin:redundantcast to "real" casts
Change-Id: Ifc9de898e5c9a084cbfd739625c679185c3a1534
Diffstat (limited to 'compilerplugins/clang/redundantcast.cxx')
-rw-r--r--compilerplugins/clang/redundantcast.cxx24
1 files changed, 13 insertions, 11 deletions
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<Foo>{bar, baz}
+ //
+ // ), at least for now:
+ auto const sub = compat::getSubExprAsWritten(expr);
+ if (isa<InitListExpr>(sub) || isa<CXXStdInitializerListExpr>(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();