summaryrefslogtreecommitdiff
path: root/compilerplugins
AgeCommit message (Collapse)Author
2017-09-18improve unusedfields lopluginNoel Grandin
(*) 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-15Fix loplugin:redundantcast's VisitCXXFunctionalCastExprStephan Bergmann
...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-14improve redundantcast lopluginNoel Grandin
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-13Enable -Wunreachable-codeStephan Bergmann
...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-11More clang::*Type vs. llvm::*Type ambiguitiesStephan Bergmann
Change-Id: I21133976793ab018c633dda077029666308526db
2017-09-11clang::Type vs. llvm::Type ambiguityStephan Bergmann
Change-Id: Idba5c15f31b25b86e2bd7b9be348a17c184fec0d
2017-09-09tdf#108572 remove connections only for current shellSzymon Kłos
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-08loplugin:unusedfieldsNoel Grandin
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-08loplugin:constantparamNoel Grandin
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-06loplugin:unnecessaryparen include case statementsNoel Grandin
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-05When traversing a TemplateDecl, ts can be a dependent typeStephan Bergmann
Change-Id: I05b02ef807a12a802720f58cd5a2d6d370b42418
2017-09-04Fix typoAndrea Gelmini
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-04loplugin:unnecessaryparen include c++ castsNoel Grandin
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-04New loplugin:dyncastvisibilityStephan Bergmann
...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-04new loplugin:redundantpointeropsNoel Grandin
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-08-31Revert loplugin:constparam behavior when param is subject of castStephan Bergmann
...cf. 72cfd4d024aa9deb68010824a804f252e37b8388 "loplugin:constparams: Also handle ObjCObjectPointerType" Change-Id: Ieec294d721002cac0c37bf2590a9ce20b3e123e3
2017-08-31Adapt lopluign:constparams to variadic CXXOperatorCallExprStephan Bergmann
Change-Id: I21c7a0fb447b5ba0a7aa0ddc690b969b156a91f3
2017-08-31Restrict loplugin:constparams cast-to-void checkStephan Bergmann
Change-Id: I3c4d4f99b423f46136a79f3b06c5f0e1492872f1
2017-08-31loplugin:constparams: Also handle ObjCObjectPointerTypeStephan Bergmann
...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...in which Johnny returns from the fair for realStephan Bergmann
and finds loplugin:constparams adapted to ObjCIvarRefExpr also Change-Id: Ib803cd80b01ad7a0fa07bddb77a873bb323a50c0
2017-08-30Avoid loplugin:constparam when param is marked as unusedStephan Bergmann
...as in entry_group_callback (sd/source/ui/remotecontrol/AvahiNetworkService.cxx), AVAHI_GCC_UNUSED void *userdata Change-Id: I494067878181c51b77d581a21ab1c9ef81e482e5
2017-08-30Avoid loplugin:constparam when param is cast to voidStephan Bergmann
...which typically indicates that the param just has to be of the given type for some reason Change-Id: Ide30f514c5a849ae897c31c1744ece9df712a9fc
2017-08-30Avoid loplugin:constparam when param is subject of cast to non-const pointerStephan Bergmann
...as in WriteCallback (desktop/source/minidump/minidump.cxx), where void *ptr is use in static_cast<char *>(ptr) Change-Id: I0bd44329029cd793390d0744de3c839612e0b494
2017-08-30Adapt loplugin:constparam to jurt/source/pipe/staticsalhack.cxxStephan Bergmann
Change-Id: I0193ce3be582cb0a06cca17257b1e6587c5b3752
2017-08-30fix ScJumpMatrixToken memory handlingNoel Grandin
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...in which Johnny returns from the fairStephan Bergmann
and finds loplugin:constparams adapted to ObjCMessageExpr Change-Id: I6e1ddd0fb1a8a61d5a78c156bccfc29f7233909e
2017-08-30loplugin:constparam in variousNoel Grandin
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-29loplugin:constparam in sc part8Noel Grandin
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-27Complete commit 61d49afadb2bAndrea Gelmini
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-25loplugin:redundantcast: suppress warnings in reworked glibc assert macroStephan Bergmann
Change-Id: I20be230b3ff5d11395f33a9896d0a575c3051fb7
2017-08-25loplugin:unusedfieldsNoel Grandin
Change-Id: I81bcf4f56599146536ba8d66cc86fa5a08737298 Reviewed-on: https://gerrit.libreoffice.org/41556 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-25loplugin:unusedmethodsNoel Grandin
Change-Id: Iaaf9092ec4d6189492906648b84494d087fed81f Reviewed-on: https://gerrit.libreoffice.org/41539 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-23loplugin:useuniqueptr, look for containers..Noel Grandin
that can use std::unique_ptr, and apply it in i18npool Change-Id: Ib410abaf73d5f392c7a7a9a322872b08c948f9e9 Reviewed-on: https://gerrit.libreoffice.org/41438 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-23ctypeitm no more existsAndrea Gelmini
File deleted on commit 08566ea51944 Change-Id: Iccf35edc92c99779be519a4c722fa5d9bcef4b34 Reviewed-on: https://gerrit.libreoffice.org/41434 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-21Adapt tests to WindowsStephan Bergmann
Change-Id: I8d33234196060f96ad47c9d0fead4f31218f8bdd
2017-08-20svtools: remove function with unused return valueJochen Nitschke
and inline only functionality Change-Id: I79b0ec29dcc35e9dc92aaac9fb191c882a9b0621 Reviewed-on: https://gerrit.libreoffice.org/41362 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-18don't use boost in compilerpluginsNoel Grandin
Change-Id: Ic1610e99cd2d11d1a536a6f3e66b44417ee59793
2017-08-18new loplugin:expressionalwayszeroNoel Grandin
The code in SvXMLExportItemMapper::exportXML was broken as far back as its introduction in commit 0c28e3c480a95c03b513c55f029b979bcd9c0401 "Move SvXMLAttrContainerItem to SVX, moved writer only code to sw" Change-Id: I90043ce8b7263aa56fd0883d350e29b97eeaf99b Reviewed-on: https://gerrit.libreoffice.org/41282 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-18Report full type info (plus the desugared type as "aka")Stephan Bergmann
Change-Id: I647b1c3e479e0be01ed7ea16e1ad3dd9bed9ba6a
2017-08-18loplugin:unnecessaryparenNoel Grandin
look for statements like return (function()); Change-Id: I906cf2183489f87225b99b987caca67e39b26cc3 Reviewed-on: https://gerrit.libreoffice.org/41260 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-17these comments no longer validNoel Grandin
Change-Id: I263116383a9342f9600d6cd1622a941afe83634e
2017-08-17fix compiler error in passparamsbyrefNoel Grandin
Under clang-3.8 we get: compilerplugins/clang/passparamsbyref.cxx:158:31: error: no member named 'isAssignmentOp' in 'clang::CXXOperatorCallExpr' Change-Id: Icfba2b624f53f07418674237adc5a47819f73c43
2017-08-17loplugin:passstuffbyref ignore params that are assigned toNoel Grandin
makes writing nice code awkward sometimes. Also split plugin into two different plugins, the logic was getting tangled up. Change-Id: I232e314d29c766c160c29373988dc37a466505be
2017-08-17new loplugin convertuintptrNoel Grandin
an experiment to see if I can make the process of eliminating sal_uIntPtr a little easier Change-Id: I808185fbf18826cb9ab5612a7be4148d52045957
2017-08-17display oncevar loplugin by defaultNoel Grandin
seems to be annoying some people. I'll run this one myself, and at some stage create some code for enabling a subset of extra plugins via configure.ac Change-Id: Ia95701f63f65751d75b5a3fecffb1fc1a82f38e0
2017-08-17add sal_uLong to droplong lopluginNoel Grandin
Change-Id: Ief92b4ee97f561613bc730a91c27fe192f485d77
2017-08-16move deadclass plugin to storeNoel Grandin
<sberg> noelgrandin, and is loplugin:deadclass even sound? struct B { B(B const &) {} }; struct D: B { D(): B(*this) {} }; Change-Id: Idadd379b925aa6f9de6c625bffa8560ec4192ac7
2017-08-16remove leftover debugging outputNoel Grandin
Change-Id: Ide78daefced91fff2efeeb25dace6f722acfa3e9
2017-08-15loplugin:redundantcast ignore functional casts involving typedefsNoel Grandin
<sberg> noelgrandin, 718cdd43c25783d9cd402e381123efe3981cc514 now also looks through typedef sugar, e.g. complaining about a gdouble -> double expl. conversion in configmgr/source/dconf.cxx; I think we want to remain silent about such conversions involving typedefs <noelgrandin> sberg, ah, good point. Change-Id: Icbb0d6be273f53e507c91556cf0ccb5a5c03e5a1 Reviewed-on: https://gerrit.libreoffice.org/41175 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-15loplugin:redundantcast, find more functional castsNoel Grandin
In the enum types that caused the problem look like this when I dump then: EnumType 0xdb45770 'enum SvxFrameDirection' `-Enum 0xdb456d8 'SvxFrameDirection' SubstTemplateTypeParmType 0xdb61200 'enum SvxFrameDirection' sugar |-TemplateTypeParmType 0xd7518f0 'EnumT' dependent depth 0 index 0 | `-TemplateTypeParm 0xd7518a8 'EnumT' `-EnumType 0xdb45770 'enum SvxFrameDirection' `-Enum 0xdb456d8 'SvxFrameDirection' Change-Id: Id8fedabe43b7a27df61a2320a9acbf54d2dc7882 Reviewed-on: https://gerrit.libreoffice.org/41169 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>