New loplugin:consttobool

Desktop / LibreOffice - Stephan Bergmann [redhat.com] - 14 November 2019 18:53 EST

...to: "Find implicit conversions from non-'bool' constants (e.g., 'sal_False') to 'bool'".

Due to how FALSE is defined as just

#define FALSE (0)

(i.e., a literal of type 'int') but TRUE is defined as

#define TRUE (!FALSE)

(i.e., an implicit conversion from 'int' to 'bool') in GLib (see the comment in ConstToBool::VisitImplicitCastExpr), we get more warnings about uses of 'TRUE' than of 'FALSE'. For example, in libreofficekit/source/gtk/lokdocview.cxx there is a warning about the 'TRUE' in

g_main_context_iteration(nullptr, TRUE);

but not about the 'FALSE' in

g_main_context_iteration(nullptr, FALSE);

(where the parameter of 'g_main_context_iteration' is of type 'gboolean'). Lets live with that asymmetry for now...

(Besides the issues addressed directly in this commit, it also found the two bogus asserts at 7e09d08807b5ba2fd8b9831557752a415bdad562 "Fix useless assert(true) (which would never fire)" and 122a0be8ae480473bd1d7f35e197a2529f4621e3 "Fix useless assert(true) (which would never fire)", plus 5f0d6df7f57ae281fe161e61c7f25d67453fddd2 "Use two-argument form of static_assert".)

Change-Id: Id77322de9f94b85a7b65608a03e0e9865d14467b Reviewed-on: https://gerrit.libreoffice.org/82667

1205a4b77401 New loplugin:consttobool
avmedia/source/gstreamer/gstplayer.cxx | 4 +-
compilerplugins/clang/consttobool.cxx | 265 +++++++++++++++++++++
compilerplugins/clang/test/consttobool.cxx | 49 ++++
connectivity/source/drivers/evoab2/NResultSet.cxx | 4 +-
connectivity/source/drivers/evoab2/NStatement.cxx | 8 +-
.../qa/gtktiledviewer/gtv-application-window.cxx | 4 +-
.../qa/gtktiledviewer/gtv-calc-header-bar.cxx | 2 +-
.../qa/gtktiledviewer/gtv-comments-sidebar.cxx | 2 +-
libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx | 2 +-
.../gtv-lokdocview-signal-handlers.cxx | 6 +-
.../qa/gtktiledviewer/gtv-signal-handlers.cxx | 34 +--
libreofficekit/source/gtk/lokdocview.cxx | 48 ++--
sd/source/ui/remotecontrol/BluetoothServer.cxx | 4 +-
solenv/CompilerTest_compilerplugins_clang.mk | 1 +
svx/source/dialog/fntctrl.cxx | 2 +-
vcl/unx/gtk3/a11y/gtk3atkcomponent.cxx | 2 +-
vcl/unx/gtk3/a11y/gtk3atklistener.cxx | 2 +-
vcl/unx/gtk3/a11y/gtk3atkselection.cxx | 8 +-
vcl/unx/gtk3/a11y/gtk3atkutil.cxx | 2 +-
vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx | 2 +-
vcl/unx/gtk3/gtk3gloactiongroup.cxx | 8 +-
vcl/unx/gtk3/gtk3glomenu.cxx | 14 +-
vcl/unx/gtk3/gtk3gtkdata.cxx | 20 +-
vcl/unx/gtk3/gtk3gtkframe.cxx | 6 +-
vcl/unx/gtk3/gtk3salprn-gtk.cxx | 4 +-
25 files changed, 409 insertions(+), 94 deletions(-)

Upstream: cgit.freedesktop.org


  • Share