summaryrefslogtreecommitdiff
path: root/compilerplugins
AgeCommit message (Collapse)AuthorFilesLines
2017-11-23Make not warning about !! in loplugin:simplifybool consistentStephan Bergmann2-3/+61
...so that 640e03da110d76b2c7d5ed5b8b8ba3b4367865ba "loplugin:simplifybool re- activate the !! warning", which did not warn about !!( nAttribs & ucb::ContentInfoAttribute::KIND_FOLDER ) in ucb/source/core/ucbcmds.cxx (involving sal_Int32 and sal_Int16), would not have warned about !!(nMode & nUpdateMode) in sfx2/source/appl/workwin.cxx (ivolving o3tl::typed_flags<SfxVisibilityFlags>) either. Change-Id: Ibe955592951a04b1bd9a9b4e8cc502024bc1d460 Reviewed-on: https://gerrit.libreoffice.org/45083 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-23Make loplugin:unnecessaryparen look through implicitStephan Bergmann2-3/+28
...similar to how <https://gerrit.libreoffice.org/#/c/45083/2> "Make not warning about !! in loplugin:simplifybool consistent" does for loplugin:simplifybool Change-Id: I23eef400af71c582d380c9bae6546ce06e8a1e18 Reviewed-on: https://gerrit.libreoffice.org/45122 Tested-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-23loplugin:simplifybool for negation of comparison operatorNoel Grandin2-17/+53
Change-Id: Ie56daf560185274754afbc7a09c432b5c2793791 Reviewed-on: https://gerrit.libreoffice.org/45068 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-22Make loplugin:unnecessaryparen warn about (x) ? ... : ... after allStephan Bergmann2-15/+1
...which had been left out because "lots of our code uses this style, which I'm loathe to bulk-fix as yet", but now in <https://gerrit.libreoffice.org/#/c/45060/1/> "use std::unique_ptr" would have caused an otherwise innocent-looking code change to trigger a loplugin:unnecessaryparen warning for pFormat = (pGrfObj) ? ... (barring a change to ignoreAllImplicit in compilerplugins/clang/unnecessaryparen.cxx similar to that in <https://gerrit.libreoffice.org/#/c/45083/2> "Make not warning about !! in loplugin:simplifybool consistent", which should also have caused the warning to disappear for the modified code, IIUC). Change-Id: I8bff0cc11bbb839ef06d07b8d9237f150804fec2 Reviewed-on: https://gerrit.libreoffice.org/45088 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-22loplugin:flatten look for large if statement at end of functionNoel Grandin2-22/+274
the rewriter is capable of flattening the function by returning early, and inverting simple conditions. More complex conditions are just wrapped in "!(x)" Change-Id: I028fd7b018dc7347c1b323b2a73ab99c18508faa Reviewed-on: https://gerrit.libreoffice.org/45071 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-22There appears to be no reason to ignore macros in these parts of...Stephan Bergmann1-22/+11
...loplugin:unnecessaryparen Change-Id: I473a1e16cf9f485a61af5477aca22798996253a3
2017-11-22loplugin:simplifybool re-activate the !! warningNoel Grandin1-2/+8
Change-Id: Iac7d82a1c228734177be536e9a6c41803c03637b Reviewed-on: https://gerrit.libreoffice.org/45035 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-20look for =() in loplugin:unnecessaryparenNoel Grandin2-17/+101
Change-Id: I4f9b71ff7767e90987bb40358fc46ed5d1d571d0 Reviewed-on: https://gerrit.libreoffice.org/44944 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-20re-enable loplugin:useuniqueptrNoel Grandin1-1/+1
Change-Id: Ic1a7e5bd3a8002ac996a6af1d1d9a439d4153b0b Reviewed-on: https://gerrit.libreoffice.org/44864 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-17Make loplugin:casttovoid more resilient against macrosStephan Bergmann1-1/+1
...in the type at the start of a ParmVarDecl, so that it does not erroneously assume in isSharedCAndCppCode that the whole decl is in "the body of a macro definition". (Even better might be to check the whole ParmVarDecl is inside one macro body.) Turns out that vcl/unx/gtk/gtkdata.cxx indirectly includes stdbool.h via some vcl/inc/unx/saldisp.hxx -> workdir/UnpackedTarball/epoxy/include/epoxy/glx.h -> workdir/UnpackedTarball/epoxy/include/epoxy/gl.h, and Clang's stdbool.h contains > /* Don't define bool, true, and false in C++, except as a GNU extension. */ > #ifndef __cplusplus > #define bool _Bool > #define true 1 > #define false 0 > #elif defined(__GNUC__) && !defined(__STRICT_ANSI__) > /* Define _Bool, bool, false, true as a GNU extension. */ > #define _Bool bool > #define bool bool > #define false false > #define true true > #endif since <http://llvm.org/viewvc/llvm-project?view=revision&revision=115028> "Define _Bool, bool, true, and false macros in <stdbool.h> when we're in a GNU-compatible C++ dialect. Fixes <rdar://problem/8477819>" while GCC's stdbool.h has meanwhile been improved with <https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=216679> "C++11 explicitly forbids macros for bool, true and false" to > #ifndef __cplusplus > > #define bool _Bool > #define true 1 > #define false 0 > > #else /* __cplusplus */ > > /* Supporting _Bool in C++ is a GCC extension. */ > #define _Bool bool > > #if __cplusplus < 201103L > /* Defining these macros in C++98 is a GCC extension. */ > #define bool bool > #define false false > #define true true > #endif > > #endif /* __cplusplus */ Change-Id: I42caab83ac6e4d5e5297376136a6bbe6f3d70818
2017-11-16Make checkIdenticalDefaultArguments more preciseStephan Bergmann2-0/+97
...by structurally comparing complex constexpr exprs that use template functions that happen to not have been instantiated, so Expr::EvaluateAsRValue et al would fail. (Which happened with SFX_PRINTER_ALL in SfxViewShell::SetPrinter, include/sfx2/viewsh.hxx.) Now all of the LO code base should compile without causing checkIdenticalDefaultArguments to return Maybe. Change-Id: I2b103418c2c68f6d2242535c9cca3222a2508778 Reviewed-on: https://gerrit.libreoffice.org/44773 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-16Avoid infinite loops in lopluginStephan Bergmann1-0/+1
...introduced with cab6e6836973a9ddfc5ed9df757e07138328c1c3 "Make checkIdenticalDefaultArguments more precise", causing older Clang to hang when compiling specific LO source files. Change-Id: I99cfcad2f0cd9adccd5aa84d21502f586762217f
2017-11-15Make checkIdenticalDefaultArguments more preciseStephan Bergmann3-16/+38
...when creating objects involves copy/move constructors Change-Id: I0c7ccb85b7dcb584502a48817d7d2abfde25aaf2 Reviewed-on: https://gerrit.libreoffice.org/44733 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-14clang-format fixStephan Bergmann1-1/+6
Change-Id: I09db5eeee5734f980a794e9adee70b6b634dfd99 Reviewed-on: https://gerrit.libreoffice.org/44732 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-14Make checkIdenticalDefaultArguments more preciseStephan Bergmann2-15/+43
...when creating objects of the same derived type Change-Id: I109b614473a2fb5b08dddd07a4fbe757086141a1 Reviewed-on: https://gerrit.libreoffice.org/44716 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-14loplugin:flatten loosen conditionNoel Grandin2-9/+26
the description in the comment was right, but the code was not Change-Id: I7c038e7453f4387d33ec6423c0c55446d6d0df47 Reviewed-on: https://gerrit.libreoffice.org/44680 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-13Fix typosAndrea Gelmini1-2/+2
Change-Id: Ia544298334364ece3b3963a4adc00c5e01189b91 Reviewed-on: https://gerrit.libreoffice.org/44654 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mark Page <aptitude@btconnect.com>
2017-11-11loplugin:unnecessaryoverride: suppress warnings when default args differStephan Bergmann5-50/+125
...instead of blacklisting such cases. Reuses the checkIdenticalDefaultArguments code that was originally in loplugin:overrideparam (and appears to work reasonably well for the default arguments that actually happen in practice). Change-Id: I9cf2db17101beb135b2039a9b7ed335bd2af2c08 Reviewed-on: https://gerrit.libreoffice.org/44594 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10loplugin:unnecessaryoverride: no warnings when fns are actually differentStephan Bergmann2-0/+21
Change-Id: I90d8af7a1affa459400b1cae4805e3a80b6c5200 Reviewed-on: https://gerrit.libreoffice.org/44593 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10No need to blacklist this loplugin:unnecessaryoverrideStephan Bergmann1-3/+0
...a using declaration should fix it just fine Change-Id: I05cf76672bcceb7a94afa602e215a0b5a32de82b Reviewed-on: https://gerrit.libreoffice.org/44591 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10No need to blacklist this loplugin:unnecessaryoverrideStephan Bergmann1-3/+0
...a using declaration should fix it just fine Change-Id: I0279994c155775e9a58e93aef8da4522d4fd93fd Reviewed-on: https://gerrit.libreoffice.org/44590 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10loplugin:unusedmethods new analysisNoel Grandin2-0/+48
look for classes containing protected methods where we can convert them all to private Change-Id: I4a448341943e0a613cde30501c4012da61dba713 Reviewed-on: https://gerrit.libreoffice.org/44588 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-10loplugin:unusedmethodsNoel Grandin2-90/+1
Change-Id: I543b0943f0bc918d59debc8ee051f88c29d18454 Reviewed-on: https://gerrit.libreoffice.org/44553 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-10No need to check both (identical) param_size() and getNumParams()Stephan Bergmann1-2/+0
Change-Id: I481cfa8b0f4bb9cbc257d28f36c372fb7367f294
2017-11-09connectivity: fix loplugin:datamembershadow warning in the Calc driverMiklos Vajna1-2/+0
Change-Id: Idcc6b1734599eec5d9eefbefb8849dc050b6a9d6 Reviewed-on: https://gerrit.libreoffice.org/44522 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2017-11-09loplugin:unusedvariable add some more std:: typesNoel Grandin1-0/+8
Change-Id: Ib15931e415990b56367fe3e1c7cf3f22cc4826d5 Reviewed-on: https://gerrit.libreoffice.org/44529 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-09loplugin:unusedfieldsNoel Grandin4-89/+110
Change-Id: Ie8a2c6462ddc708140e725847199c8234ab6b592 Reviewed-on: https://gerrit.libreoffice.org/44528 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-09No need to blacklist this loplugin:unnecessaryoverrideStephan Bergmann1-3/+0
This now hides one of the ScVbaFormatCondition_BASE::Operator overloads, but that doesn't get called directly at ScVbaFormatCondition anyway. (And if it were, we could add an appropriate using declaration to ScVbaFormatCondition.) Change-Id: I8440b76a5745c6874f7a3bfcbb4bc4ce5618a4c4
2017-11-09new loplugin simplifydynamiccastNoel Grandin2-0/+150
simplify dynamic_cast followed by static_cast Change-Id: I965afcf05d1675094cfde53d3590a0fd00f26279 Reviewed-on: https://gerrit.libreoffice.org/44460 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-09loplugin:unnecessaryvirtualNoel Grandin1-37/+37
Change-Id: I5696c853daa16c9e55ff046d67102ba3042bfea8 Reviewed-on: https://gerrit.libreoffice.org/44459 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-08Fix loplugin::unusedvariablecheck check for std classesStephan Bergmann2-8/+31
(but which finds no new hits) Change-Id: I862a3c82932ee6d6d0946cd33f965bb8e917cff8
2017-11-08Drop HAVE_GCC_ATTRIBUTE_WARN_UNUSED_STLStephan Bergmann1-7/+0
For one, loplugin:unusedvariablecheck does not merely check for unused variables with types from the standard library since fe2164949b38a7f73883dbdcb3271b94e5c81744 "teach unusedvariablecheck plugin about SfxPoolItem subclasses", so disabling loplugin:unusedvariablecheck based on HAVE_GCC_ATTRIBUTE_WARN_UNUSED_STL is wrong. For another, I have seen no standard library implementation that decorates its types with such "warn-if-unused" attributes, and <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0600r0.pdf> "[[nodiscard]] in the Library" (which proposes to add the corresponding C++17 attribute to just a few select functions and no types at all) makes it appear unlikely that will happen. Change-Id: I0a7759e1caf3e3137057c9689080948a4d6747e0
2017-11-08Fix loplugin:flatten's skipping of if/then/else/if chainsStephan Bergmann2-5/+45
(but which finds no new hits) Change-Id: I5d5f351402797b662a08ec8dca301bd174e22a50 Reviewed-on: https://gerrit.libreoffice.org/44433 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-08Remove obsolete "lo_warn_unused" workaroundStephan Bergmann1-12/+0
Per README.md, Clang 3.4 is the baseline for --enable-compiler-plugins, which is the sole consumer of the "lo_warn_unused" attribute, but Clang 3.4 already supports HAVE_GCC_ATTRIBUTE_WARN_UNUSED. Change-Id: I9654028e24852335e463c73bcb5ece5e5b54d53c
2017-11-08Suppress loplugin:unnecessaryoverride...Stephan Bergmann2-7/+100
...when a class derives from multiple (non-virtual) instances of one base class, and the override disambiguates which of those instances' member to call. That was the case with SwXTextDocument::queryAdapter (sw/source/uibase/uno/unotxdoc.cxx), where SwXTextDocument derives from cppu::OWeakObject through both SwXTextDocumentBaseClass and SfxBaseModel, but calling queryAdapter through a pointer to SwXTextDocumentBaseClass apparently needs to call OWeakObject::queryAdapter on the second, SfxBaseModel-inherited OWeakObject base instance, or else CppunitTest_sw_macros_test fails. Who knows what other instances of similar non-unnecessary overrides have been removed with the help of broken loplugin:unnecessaryoverride, for which there were no tests that started to fail... Turns out .clang-format lacked "ReflowComments: false" to not break the special "// expected-error {{...}}" etc. comments in compilerplugins/clang/test/. Also, use a better location to report loplugin:unnecessaryoverride, to keep clang-format and loplugin:unnecessaryoverride from fighting over how to split lines and where to put the comment in compilerplugins/clang/test/unnecessaryoverride.cxx. Change-Id: I3b24df24369db12f8ec1080d6c9f7b70ff561a16 Reviewed-on: https://gerrit.libreoffice.org/44418 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-07Remove obsolete commentStephan Bergmann1-1/+0
...that should have been removed in 2446d2b2fb8b091eaae015fd5bb26bd8e0f596f7 "Avoid expensive calls to containsPreprocessingConditionalInclusion" Change-Id: I2ffe0ec7b6f1ec0b418979f2864bd5de79ab2c9a
2017-11-07Avoid expensive calls to containsPreprocessingConditionalInclusionStephan Bergmann1-13/+14
Change-Id: I42981a23f75298591b2c3b073aea66426220f3e2
2017-11-07loplugin:constparams in sdNoel Grandin1-0/+20
Change-Id: Id4b68ca0509111396ed354f4cda43d663083cad0 Reviewed-on: https://gerrit.libreoffice.org/44388 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-07Clean away temporarily added using declarationsStephan Bergmann86-106/+160
Change-Id: I26734c13515394162d88351a1cbe2b20abdac865
2017-11-07Memoize ignoreLocation resultsStephan Bergmann4-67/+100
...which, according to callgrind, reduces instruction fetch count spent on compiling sw/source/core/layout/paintfrm.cxx (randomly selected because it is rather large) by 5% from 41,992,064,226 to 39,861,989,855 (function main() in clang-6.0). This is best done by forwarding ignoreLocation calls from Plugin to the PluginHandler signleton, but due to the tight mutual coupling between plugin.hxx and pluginhandler.hxx that unfortunately required some reorganization (and two outstanding TODO clean-ups of temporarily introduced using declarations in plugin.hxx). Change-Id: Ia4270517d194def7db7ed80cb6894e9c473e9499
2017-11-02improve constparam lopluginNoel Grandin2-94/+165
lots of little fixes to make the logic less pessimistic Change-Id: If368822984250b11b98c56f5890177a1402e8660 Reviewed-on: https://gerrit.libreoffice.org/44168 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-01-I$(dir $(3)) in gb_CObject__command_pattern is no longer neededStephan Bergmann2-2/+2
...at least in com_GCC_class.mk (com_MSC_class.mk will be addressed in a follow- up commit), after the recent loplugin:includeform clean-up. Two static libraries built from external sources needed adjustment, two compilerplugin tests needed adjustment (which wasn't found by loplugin:includeform, by design), and one more adjustment in sal/textenc/generate/. Change-Id: Idad5ae355a02ae130369a9a45b5f5925ab48ffef Reviewed-on: https://gerrit.libreoffice.org/44174 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-10-30new loplugin: constmethodNoel Grandin2-0/+569
parked in store/ for now, because, as I worked my way up the layers of modules, the higher I got, the more false+ I got when trying to only make changes that preserved logical-constness. Change-Id: I4acd2c4416775f7c6a3d91eb0bce048630ccaff5
2017-10-27Adapt loplugin:includeform to Windows \ path separatorStephan Bergmann3-13/+35
This can also call loplugin::isSamePathname with two paths that both contain backslashes, so finally make it (and hasPathnamePrefix) symmetric in which arguments my contain backslashes. Change-Id: I0465988d9d41e21c5660cbdbd1558543860ae1ad
2017-10-27revert small part of previous commitNoel Grandin1-3/+2
not necessary after all Change-Id: I050ed0cc140969f2d32839f3a7841b240fd0efd0
2017-10-27extract some common code for checking if a functions address was takenNoel Grandin4-106/+138
Change-Id: I292b4e9bf17c83f83ff43ac4c5870d33092d0c71
2017-10-27-Werror=unused-functionStephan Bergmann1-67/+0
Change-Id: I2858c6cb74b96ffe6a799dc2ab02cbbe1c56abc7
2017-10-27loplugin:constantparam was not always using canonical location for functionNoel Grandin1-5/+4
Change-Id: I8a15da534ba2cf9968cba0ee1f1bb74d7e3a0d54
2017-10-27no need to build the parent tree twiceNoel Grandin2-21/+8
lets just use the built in parents stuff Change-Id: I7bb705acfcd6c8c18168676b0cdb13c26ba5b95a
2017-10-27rename loplugin::Plugin::parentStmtNoel Grandin12-24/+24
to getParentStmt and rename parentFunctionDecl to getParentFunctionDecl, so I don't keep using accidentally naming my variables the same as the functions. Change-Id: I66f9452458c8b439e5132191ac5219fb6d420708