1454 Commits

Author SHA1 Message Date
Stephan Bergmann
f79123a823 loplugin:stringconstant: Also handle u8"..." strings
(just in case)

Change-Id: Id8ce7436bacba874d9bc04915e42622e3cfca67a
2017-09-27 07:53:00 +02:00
Tor Lillqvist
8e7897588d Rename the basegfx::tools namespace to basegfx::utils
Reduce potential confusion with the global tools namespace. Will
hopefully make it possible to remove the annoying initial :: when
referring to the global tools namespace. Unless we have even more
tools subnamespaces somewhere.

Thorsten said it was OK.

Change-Id: Id088dfe8f4244cb79df9aa988995b31a1758c996
Reviewed-on: https://gerrit.libreoffice.org/42644
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2017-09-26 14:18:41 +02:00
Noel Grandin
ade2769232 improve unnecessarycatchthrow plugin
it is not legal to eliminate a catch/re-throw where the re-throw
expliciting mentions the exception variable and the exception variable
is a non-final class

Change-Id: I7fd88b0d004d2efa66aef2c0876e07f203da3c28
Reviewed-on: https://gerrit.libreoffice.org/42782
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-26 11:27:08 +02:00
Stephan Bergmann
d883e3556a loplugin:redundantcast: cstyle_cast within reinterpret_cast
Change-Id: Ie31c9dd6d8741aa856553b798bb5b7f695a3fe0f
Reviewed-on: https://gerrit.libreoffice.org/42776
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-26 10:01:54 +02:00
Andrea Gelmini
e44c188a73 Fix typos
Change-Id: I879a52820d78d9151ef64dd21612379f617f66e2
Reviewed-on: https://gerrit.libreoffice.org/42726
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2017-09-25 12:20:56 +02:00
Noel Grandin
ee6bdeec8d loplugin:flatten in svl..svx
and implement a check in the plugin to prevent us modifying the
same patch of source code twice. This logic should probably be moved
into plugin.cxx at some point.

Change-Id: I7ebff6424cc8733bb2c8f7dba75eaaec68649290
Reviewed-on: https://gerrit.libreoffice.org/42660
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-23 09:04:48 +02:00
Noel Grandin
2684aefcf5 new loplugin unnecessarycatchthrow
Change-Id: Iabab71ee076227bc38447ec109afaea1e53a86a6
Reviewed-on: https://gerrit.libreoffice.org/42643
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-23 09:01:46 +02:00
Noel Grandin
a7ce8404be loplugin:flatten in pyuno..sc
Change-Id: I7ddc0b76532d26910f78642200750459508c2861
Reviewed-on: https://gerrit.libreoffice.org/42617
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-22 13:48:25 +02:00
Stephan Bergmann
5c54b6523f loplugin:stringconstant: warn about explicit length mismatch
(just in case)

Change-Id: I9eaf6e920fc7fc3ebc8c705df1cdf34b325db74a
Reviewed-on: https://gerrit.libreoffice.org/42614
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-22 13:45:07 +02:00
Eike Rathke
d80ba7354c Ditch now unused GraphicExportDialog, GraphicExportOptionsDialog
That was a dead end anyway, trying to partly reimplement
SvFilterOptionsDialog ExportDialog, instead of implementing the
necessary bits to use that one which has everything.

Change-Id: Icde7422f2c2d7e26c07dfe921a4abda41e222b09
Reviewed-on: https://gerrit.libreoffice.org/42503
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
2017-09-22 13:28:31 +02:00
Noel Grandin
b9de047454 loplugin:flatten in scaddins..sd
Change-Id: I190323ce910224f883c4370b2c752644a5a35edd
Reviewed-on: https://gerrit.libreoffice.org/42626
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-22 13:06:24 +02:00
Michael Stahl
0fbfdce3ea compilerplugins: add test for badstatics
Change-Id: Ibdb3144c0510ed723a01ca28d7cdcd6b21caec54
Reviewed-on: https://gerrit.libreoffice.org/42596
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2017-09-22 10:59:42 +02:00
Noel Grandin
b63609ba54 loplugin:flatten in framework..package
Change-Id: Ide8a97eae6e2fdc7d2dcccba1480ac55a9b555bc
Reviewed-on: https://gerrit.libreoffice.org/42593
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-22 08:30:10 +02:00
Stephan Bergmann
7b45044fd1 Also handle OUString with non-RTL_TEXTENCODING_ASCII_US encoding
(just in case)

Change-Id: I7ba2967c1cef81a3f6604077d876c8b993f7f16a
Reviewed-on: https://gerrit.libreoffice.org/42609
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-22 08:19:55 +02:00
Stephan Bergmann
6ac0dc7003 -Werror=unused-but-set-variable
Change-Id: I8bdf8a4c04256ad665960dd6f0d71d032156a34b
2017-09-21 15:55:08 +02:00
Noel Grandin
3a481dde03 loplugin:flatten in editeng..extensions
Change-Id: I2b68f5640471ea827c09af1b5a319fb526a53b4b
Reviewed-on: https://gerrit.libreoffice.org/42579
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-21 15:29:20 +02:00
Noel Grandin
ac80f048f2 loplugin:flatten in basctl..configmgr
Change-Id: I674cad57ce30a885e126d3bcc921f8fcb53dc36d
Reviewed-on: https://gerrit.libreoffice.org/42577
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-21 15:18:57 +02:00
Samuel Mehrbrodt
b649e5bf1d Rename GetSelectEntry -> GetSelectedEntry
Change-Id: Ibb7d8c59c0e61b0e87455bd78f241d8691dd9dce
Reviewed-on: https://gerrit.libreoffice.org/42282
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2017-09-21 12:44:00 +02:00
Noel Grandin
e8b5ec6590 loplugin:unusedfields, fix var taking ref
Change-Id: I0ea1f0c7488c140fca9f64de326c6ac588ece925
2017-09-21 10:01:43 +02:00
Noel Grandin
dc97ede7cf new loplugin flatten
look for places where we can flatten the control flow in a method by
exiting early with a throw, ie. instead of

   if (cond)
       stuff();
   else
       throw ex;

we  change it to:

   if (!cond)
      throw ex;
   stuff();

Change-Id: I8b6bdf883b325807c7e3a3ef698e4f4606e7d38b
2017-09-20 12:42:33 +02:00
Noel Grandin
1ff0f0ba29 improve unusedfields loplugin
(*) IsPassedByNonConst was completely wrong, not even sure why it worked
before.
(*) treat a field passed to operator>>= as being written to, but not
read

Change-Id: Id3a5f2f35222986fe5edba3f5a58215a1815d401
2017-09-18 09:45:15 +02:00
Stephan Bergmann
7282b25f22 Fix loplugin:redundantcast's VisitCXXFunctionalCastExpr
...when t1 is ElaboratedType sugar (which isn't only used when the type is
written with an elaborated type keyword, but also when it is written with a
qualified name).

(I originally wrote testArithmeticTypedefs to track down a different issue,
which turned out to be a non-issue, with this fix as fall-out.  So that test
doesn't quite match the theme of this commit, but is a worthwhile addition
nonetheless.)

Change-Id: Ic447da4399853d7d045e3e2e7ade8ddf52d89749
2017-09-15 18:50:45 +02:00
Noel Grandin
5685ee25aa improve redundantcast loplugin
to find c-style casts where the expression is a templated method

Change-Id: Ifbd1e2cdc72d906fc95a7ec0f9408c3f6d2a836b
Reviewed-on: https://gerrit.libreoffice.org/42275
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-14 14:43:43 +02:00
Stephan Bergmann
7f3ca30951 Enable -Wunreachable-code
...motivated by <https://gerrit.libreoffice.org/#/c/41565/2> adding dead code
at the end of a switch statement, after the last case's "break".

-Wunreachable-code appears to work well on Clang, while it appears to have no
effect on GCC.

Most of the affected places are apparently temporary/TODO/FIXME cases of
disabling code via "if (false)", which can be written with an extra set of
parentheses as "if ((false))" to silence -Wunreachable-code on Clang (which thus
needed loplugin:unnecessaryparen to be adapted accordingly).  In some cases,
the controlling expression was more complex than just "false" and needed to be
rewritten by taking it out of the if statement to silence Clang.

One noteworthy case where the nature of the disabled code wasn't immediately
apparent:

  Sep 12 16:59:58 <sberg> quikee, is that "if (false)" in
   ScExponentialSmoothingDialog::ApplyOutput
   (sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx) some work-in-
   progress or dead code?
  Sep 12 17:02:03 <quikee> sberg: WIP, but you can remove it
  Sep 12 17:04:47 <sberg> quikee, I'll wrap the false in an extra set of
   parentheses for now, to silence -Wunreachable-code (I wouldn't want to
   remove it, as I have no idea whether I should then also remove the "Initial
   value" comment preceding it)
  Sep 12 17:07:29 <quikee> sberg: both are different ways to calculate the
   "intital value"... so no

Another case where the nature of the dead code, following while (true) loops
without breaks, is unclear is sd/source/ui/remotecontrol/BluetoothServer.cxx,
where I added TODO markers to the workarounds that silence the warnings for now.

basic/source/sbx/sbxvalue.cxx had a variable of type double, of automatic
storage duration, and without an initalizer at the top of a switch statement.
Clang warning about it is arguably a false positive.

Apart from that, this didn't find any cases of genuinely dead code in the
existing code base.

Change-Id: Ib00b822c8efec94278c048783d5997b8ba86a94c
Reviewed-on: https://gerrit.libreoffice.org/42217
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-13 10:24:38 +02:00
Stephan Bergmann
b4c9c0d137 More clang::*Type vs. llvm::*Type ambiguities
Change-Id: I21133976793ab018c633dda077029666308526db
2017-09-11 10:48:12 +02:00
Stephan Bergmann
5bbfa7ab8d clang::Type vs. llvm::Type ambiguity
Change-Id: Idba5c15f31b25b86e2bd7b9be348a17c184fec0d
2017-09-11 10:29:01 +02:00
Szymon Kłos
97477ee5e1 tdf#108572 remove connections only for current shell
Also remove connections to temp files.

Change-Id: Ie5c09eb365d1246e053dc52884c72687ac226f3c
Reviewed-on: https://gerrit.libreoffice.org/42095
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
2017-09-09 11:42:50 +02:00
Noel Grandin
a84026031d loplugin:unusedfields
Change-Id: Ie26c52090d984c40cc108c9f20eb2ba31a866796
Reviewed-on: https://gerrit.libreoffice.org/42090
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-08 09:37:59 +02:00
Noel Grandin
2e0a25ce2b loplugin:constantparam
Change-Id: Ic87f0cc863490858b7cc7e74a7f90ec31992dd53
Reviewed-on: https://gerrit.libreoffice.org/42089
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-08 09:19:32 +02:00
Noel Grandin
dccd1633a1 loplugin:unnecessaryparen include case statements
Change-Id: I79fb3eec0d5d466e33b2e18621a7169695edf82f
Reviewed-on: https://gerrit.libreoffice.org/41920
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-06 08:43:33 +02:00
Stephan Bergmann
4f2bc21685 When traversing a TemplateDecl, ts can be a dependent type
Change-Id: I05b02ef807a12a802720f58cd5a2d6d370b42418
2017-09-05 09:38:58 +02:00
Andrea Gelmini
a40d37b4d6 Fix typo
Change-Id: Iab1878108420c2437f9d7e36696a68b1cfb024f9
Reviewed-on: https://gerrit.libreoffice.org/41890
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2017-09-04 14:39:10 +02:00
Noel Grandin
7aa7f4d9e4 loplugin:unnecessaryparen include c++ casts
Change-Id: I132d3c66f0562e2c37a02eaf4c168d06c2b473eb
Reviewed-on: https://gerrit.libreoffice.org/41874
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-04 10:52:41 +02:00
Stephan Bergmann
595371e520 New loplugin:dyncastvisibility
...to find uses of dynamic_cast where the static (base) type has hidden
visibility while the dynamic (derived) one has default visibility, and which may
thus fail at least on macOS like happened in
d5ed3cd6dbd22bb18542778f1c48f4d5b3ae0f95 "Make WinMtfFontStyle's base class
EMFIO_DLLPUBLIC, too".

libcxxabi's __dynamic_cast takes static_type and dst_type arguments.  Now, if
dst_type (the derived type, with default visibility) is taken from .so A (and
thus references the version of the base type info hidden in .so A) but the
__dynamic_cast call is made from .so B, it passes for static_type the base type
information hidden in .so B, and __dynamic_cast will consider the cast to fail.
I'm not sure whether hidden intermediary types (in the hierarchy between the
dynamic_cast's base and derived types) acutally cause a problem too, but lets
flag them with the plugin anyway.

The fixes use SAL_DLLPUBLIC_RTTI.  For one, there appear to be no other reasons
than type visibility to make those classes SAL_DLLPUBLIC.  For another, this
nicely avoids any actual changes on Windows (where SAL_DLLPUBLIC expands to
nothing, and many of the affected classes were explicityl introduced into class
hierarchies as "MSVC hacks").

Change-Id: Ia85a9635cebffb1009a9efc1484b8bd4025585d4
Reviewed-on: https://gerrit.libreoffice.org/41802
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-04 09:08:16 +02:00
Noel Grandin
326295bf10 new loplugin:redundantpointerops
Change-Id: I8428d86ea9628d69c2b40b36feee3da428a9fe1d
Reviewed-on: https://gerrit.libreoffice.org/41787
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-04 08:44:19 +02:00
Stephan Bergmann
36910b444c Revert loplugin:constparam behavior when param is subject of cast
...cf. 72cfd4d024aa9deb68010824a804f252e37b8388 "loplugin:constparams: Also
handle ObjCObjectPointerType"

Change-Id: Ieec294d721002cac0c37bf2590a9ce20b3e123e3
2017-08-31 17:55:52 +02:00
Stephan Bergmann
6d57d6c40f Adapt lopluign:constparams to variadic CXXOperatorCallExpr
Change-Id: I21c7a0fb447b5ba0a7aa0ddc690b969b156a91f3
2017-08-31 12:14:41 +02:00
Stephan Bergmann
4082b5874a Restrict loplugin:constparams cast-to-void check
Change-Id: I3c4d4f99b423f46136a79f3b06c5f0e1492872f1
2017-08-31 11:23:26 +02:00
Stephan Bergmann
72cfd4d024 loplugin:constparams: Also handle ObjCObjectPointerType
...in 0660a30d54eb6762302cf1afd43de01e137f6393 "Avoid loplugin:constparam when
param is subject of cast to non-const pointer"

But turns out this whole avoidance is ill-advised and should eventually be
reverted:

Aug 31 09:09:26 <sberg> noelgrandin, the way you originally handled CastExpr in
 constparam's checkIfCanBeConst, your intent was if there's code like
 static_cast<T*>(p) and param p is found it can be made const, one would also
 need to change that cast to static_cast<T const *>(p) when fixing the loplugin
 warning, right?
Aug 31 09:09:43 <noelgrandin> sberg, correct
Aug 31 09:10:10 <sberg> noelgrandin, I messed the up with
 0660a30d54eb6762302cf1afd43de01e137f6393
Aug 31 09:10:12 <IZBot> core - Avoid loplugin:constparam when param is subject
 of cast to non-const pointer -
 http://cgit.freedesktop.org/libreoffice/core/commit/?id=0660a30d54eb6762302cf1afd43de01e137f6393
Aug 31 09:10:24 <noelgrandin> sberg, I probably should have had a test for that
Aug 31 09:10:41 <noelgrandin> tests are better at expressing intent
Aug 31 09:10:56 <sberg> I ran across it in a function that needed to have the
 param non-const for API reasons (callback fn), and it looked like the "obvious"
 fix there, not needing to add the fn to the blacklist
Aug 31 09:11:26 <sberg> I'll eventually get that fixed again (but want to first
 get the Mac and Windows builds to succeed)
Aug 31 09:11:44 <noelgrandin> fair enough

Change-Id: Idef0cfc417ec0597a26a29c8720e3e4051a68e00
2017-08-31 11:13:38 +02:00
Stephan Bergmann
20b11e8dc4 ...in which Johnny returns from the fair for real
and finds loplugin:constparams adapted to ObjCIvarRefExpr also

Change-Id: Ib803cd80b01ad7a0fa07bddb77a873bb323a50c0
2017-08-31 11:02:38 +02:00
Stephan Bergmann
64a4ad3a67 Avoid loplugin:constparam when param is marked as unused
...as in entry_group_callback
(sd/source/ui/remotecontrol/AvahiNetworkService.cxx),

  AVAHI_GCC_UNUSED void *userdata

Change-Id: I494067878181c51b77d581a21ab1c9ef81e482e5
2017-08-30 16:34:46 +02:00
Stephan Bergmann
5d2e830a30 Avoid loplugin:constparam when param is cast to void
...which typically indicates that the param just has to be of the given type for
some reason

Change-Id: Ide30f514c5a849ae897c31c1744ece9df712a9fc
2017-08-30 15:14:19 +02:00
Stephan Bergmann
0660a30d54 Avoid loplugin:constparam when param is subject of cast to non-const pointer
...as in WriteCallback (desktop/source/minidump/minidump.cxx), where

  void *ptr

is use in

  static_cast<char *>(ptr)

Change-Id: I0bd44329029cd793390d0744de3c839612e0b494
2017-08-30 14:57:46 +02:00
Stephan Bergmann
67bff64e10 Adapt loplugin:constparam to jurt/source/pipe/staticsalhack.cxx
Change-Id: I0193ce3be582cb0a06cca17257b1e6587c5b3752
2017-08-30 14:57:10 +02:00
Noel Grandin
80dd56035e fix ScJumpMatrixToken memory handling
ScJumpMatrixToken unconditionally deletes the ScJumpMatrix pointer it
receives. But it's copy constructor also just copies that pointer,
meaning that we could end up freeing that pointer twice.

ScJumpMatrix has no copy constructor, so I just managed it via
shared_ptr.

Change-Id: I9cf13312afb4f2869fdc878e5f34060614e31842
Reviewed-on: https://gerrit.libreoffice.org/41728
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-30 13:23:15 +02:00
Stephan Bergmann
99fb14ef72 ...in which Johnny returns from the fair
and finds loplugin:constparams adapted to ObjCMessageExpr

Change-Id: I6e1ddd0fb1a8a61d5a78c156bccfc29f7233909e
2017-08-30 12:22:19 +02:00
Noel Grandin
008199ee75 loplugin:constparam in various
Change-Id: I6821a3946f2e8fabf26558a84370c16ac8827fed
Reviewed-on: https://gerrit.libreoffice.org/41721
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-30 10:58:56 +02:00
Noel Grandin
bcc372d15e loplugin:constparam in sc part8
Change-Id: I6cf9c5e662b20de9c9698a8c1fab56a09950c522
Reviewed-on: https://gerrit.libreoffice.org/41683
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-29 14:15:16 +02:00
Andrea Gelmini
b382193a20 Complete commit 61d49afadb2b
Change-Id: I299d112f7189335e17bc0062447ecc051ec24fa9
Reviewed-on: https://gerrit.libreoffice.org/41284
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2017-08-27 13:27:18 +02:00
Stephan Bergmann
c5616014bb loplugin:redundantcast: suppress warnings in reworked glibc assert macro
Change-Id: I20be230b3ff5d11395f33a9896d0a575c3051fb7
2017-08-25 20:21:25 +02:00