Commit Graph

461 Commits

Author SHA1 Message Date
Noel Grandin
b52f309f2b improve loplugin simplifyconstruct
to find stuff like
   OUString s = OUString("xxx")

Change-Id: Ie7ed074c1ae012734c67a2a89c564c1900a4ab04
Reviewed-on: https://gerrit.libreoffice.org/70697
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-15 08:37:54 +02:00
Noel Grandin
b65f3fbb2b new loplugin sequentialassign
Look for places we are assigning to the same variable twice
in succession, which means we can simplify that to a single assign

Change-Id: I499d20e28f5595e81e927bef8e1bf364eea8ba91
Reviewed-on: https://gerrit.libreoffice.org/70531
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-11 08:52:49 +02:00
Stephan Bergmann
88b076c459 Adapt to Windows sal_uIntPtr/sal_uLong typedefs
Change-Id: Ic6f269f75e2b64e0c2a53455e9ee4ccf9891cfb0
Reviewed-on: https://gerrit.libreoffice.org/69807
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-03-27 14:17:39 +01:00
Stephan Bergmann
be0655364c Improve loplugin:typedefparam error reporting
Change-Id: I2ed4c20ab909b79fca794fb04259018fbfcb1db5
Reviewed-on: https://gerrit.libreoffice.org/69787
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-03-27 10:57:46 +01:00
Noel Grandin
b1cfdb7bee new loplugin:unoquery
look for places we are doing code like:

    Reference<XProperty>(model, css::uno::UNO_QUERY)->getAsProperty()

which might result in a SIGSEGV is the query fails

Change-Id: I5cbdbc9e64bd0bed588297c512bf60cbacb9442e
Reviewed-on: https://gerrit.libreoffice.org/69044
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-25 07:19:13 +01:00
Noel Grandin
5c23459245 new loplugin constvars
detect static variables that can be made const.

Thanks to mike kaganski for suggesting this.

Here I introduce a new plugin feature - using markers
in nearby comments to disable the plugin for specific
vars.

Some of this stuff was old debugging code. I removed the stuff
that was older than 5 years.

Change-Id: I6ec7742a7fdadf28fd128b592fcdf6da8257585c
Reviewed-on: https://gerrit.libreoffice.org/68807
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-08 07:20:29 +01:00
Noel Grandin
cfd080d00a loplugin:staticconstfield improve warning message
Change-Id: I000dff6b1b6e33e1b2c5aa337c027c1edd7b1003
Reviewed-on: https://gerrit.libreoffice.org/68795
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-06 11:06:22 +01:00
Noel Grandin
a2e3705d8b loplugin:unnecessaryparen improve member expression
Change-Id: I304621018cb1e2a47e478e86df4229bcf2176741
Reviewed-on: https://gerrit.libreoffice.org/68757
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-06 06:47:06 +01:00
Noel Grandin
191f85df58 re-land "new loplugin typedefparam""
This reverts commit c9bb48386b,
and adds a bunch more fixes.

Change-Id: Ib584d302a73125528eba85fa1e722cb6fc41538a
Reviewed-on: https://gerrit.libreoffice.org/68680
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-05 12:12:26 +01:00
Noel Grandin
c9bb48386b Revert "new loplugin typedefparam"
This reverts commit 9865440d21.

This is not ready to land yet, seems like the latest update
of the logic reveals a bunch more places I need to fix before it can land.
2019-03-04 08:56:11 +02:00
Noel Grandin
9865440d21 new loplugin typedefparam
verify that parameters use the exact same typedef-names (if any)
in definition and declaration

Change-Id: I55d2817f599b0253904dce2d35a1a93967e15a77
Reviewed-on: https://gerrit.libreoffice.org/68439
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-04 07:32:43 +01:00
Noel Grandin
48dc1e48d0 loplugin:unnecessaryoverride look for more patterns
like
   bool Foo::bar() {
       b = Super::bar();
       return b;
   }

Change-Id: I5e4c8005a3da7d7487c9039c35dcbb1d17e65bd7
Reviewed-on: https://gerrit.libreoffice.org/68418
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-27 09:13:25 +01:00
Noel Grandin
57ac2fcdda loplugin:unusedfields fix read/write when dealing with r<<= and >>=
Change-Id: I103bcc2f21741d0a52a0bdf053fdbddf5a3e9ea0
Reviewed-on: https://gerrit.libreoffice.org/68387
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-27 07:36:12 +01:00
Noel Grandin
4d502ef355 loplugin:simplifybool improve search for negated operator
Change-Id: Id6ac35fefa5c3e1f64c222713791e849b3cb4d34
Reviewed-on: https://gerrit.libreoffice.org/68379
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-27 07:35:11 +01:00
Andrea Gelmini
e99a7a8dfa Fix typo
Change-Id: I428b4c484ba6e18ee2947c9be4688317764769f2
Reviewed-on: https://gerrit.libreoffice.org/68240
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-02-23 14:19:19 +01:00
Stephan Bergmann
b87f3dc3c5 loplugin:writeonlyvars is no-op on Windows, so don't run its test there
But nevertheless, make sure that the variables m_bar9/10 used in combination
with css::uno::Any have UNO-compatible type.

Change-Id: I4e9915193386278ace128df94f7722d90b2567f2
Reviewed-on: https://gerrit.libreoffice.org/68195
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-02-22 13:35:22 +01:00
Noel Grandin
5febdea1d1 loplugin:unusedfields improve write-only when dealing with operators
Change-Id: I3a060d94de7c3d77a54e7f7f87bef88458ab5161
Reviewed-on: https://gerrit.libreoffice.org/68132
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-21 12:04:28 +01:00
Stephan Bergmann
0626e66d76 Avoid loplugin:indentation after preproc conditional inclusion lines
...to not trigger (for --disable-dbgutil) at

>                         rContentAtPos.eContentAtPos = IsAttrAtPos::TableBoxFml;
> #ifdef DBG_UTIL
>                         if( RES_BOXATR_VALUE == pItem->Which() )
>                             rContentAtPos.eContentAtPos = IsAttrAtPos::TableBoxValue;
>                         else
> #endif
>                             const_cast<SwTableBoxFormula*>(static_cast<const SwTableBoxFormula*>(pItem))->PtrToBoxNm( &pTableNd->GetTable() );

(sw/source/core/crsr/crstrvl.cxx:1710)

Change-Id: I8fd5c8a1cd40450bdd8cc97057e5233a0134f044
Reviewed-on: https://gerrit.libreoffice.org/68030
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-02-20 11:14:55 +01:00
Stephan Bergmann
893ee43180 Tell about presumed corresponding negated operator
Change-Id: Ic7ed64ecc4902853dc7431294484abb74e8da65b
Reviewed-on: https://gerrit.libreoffice.org/67953
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-02-18 10:22:48 +01:00
Noel Grandin
aa51774e6a loplugin:simplifybool, check for !(!a op !b)
Change-Id: Ic3ee9c05705817580633506498f848aac3ab7ba6
Reviewed-on: https://gerrit.libreoffice.org/67866
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-18 07:15:57 +01:00
Noel Grandin
e132e781d8 loplugin:simplifybool extend to !(a == b) where comparison an overloaded op
Change-Id: I08fcbe2569c07f5f97269ad861fa6d38f23a7cc7
Reviewed-on: https://gerrit.libreoffice.org/67816
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-15 11:52:41 +01:00
Stephan Bergmann
bf1a511f9c Make loplugin:stringconcat more robust
Change-Id: Ib8adefd90141007c0422b4c15ba9c2cc5f707f3f
Reviewed-on: https://gerrit.libreoffice.org/67762
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-02-13 13:56:12 +01:00
Noel Grandin
0d1253c232 new loplugin writeonlyvars
largely based on the relevant portion of the unusedfields loplugin, but
adapted for local vars

Change-Id: Ic522a941573940e8f75c88f90ba5f37508ca49b1
Reviewed-on: https://gerrit.libreoffice.org/66835
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-11 13:25:31 +01:00
Noel Grandin
f76bf262a6 new loplugin indentation
look for mixed indentation in compound statements, which makes them hard
to read, and sometimes makes it look like a statement is associated with
a nearby if/for

Change-Id: Ic8429cee1f9a86d938097a4a8769a2bce97b3361
Reviewed-on: https://gerrit.libreoffice.org/63283
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-02-11 08:24:19 +01:00
Stephan Bergmann
8949f98d16 loplugin:unusedfileds is no-op on Windows, so don't run its test there
But nevertheless, make sure that the variables m_bar9/10 used in combination
with css::uno::Any have UNO-compatible type.

Change-Id: I241d8b5d37de60b00b5bfdc69e642872b28e8ee2
Reviewed-on: https://gerrit.libreoffice.org/67201
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-31 14:13:22 +01:00
Noel Grandin
a6358f1c1b improve loplugin constparams
Change-Id: Ic1833dbd030044011e7ee5f89dc35737e5469f05
Reviewed-on: https://gerrit.libreoffice.org/66586
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-01-25 07:58:04 +01:00
Noel Grandin
924da47e03 update useunique_ptr loplugin
with more exclusions

Change-Id: I95e7376ecf9c479d05b85c71f863d9ba40417538
Reviewed-on: https://gerrit.libreoffice.org/66552
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-01-18 07:51:04 +01:00
Noel Grandin
61dfcdda88 loplugin:unusedfields improve write-only logic
when dealing with modifications to container classes (e.g. std::vector)

Change-Id: Ic30043631007355ee9a3d9e3f9b6488b435182d6
Reviewed-on: https://gerrit.libreoffice.org/65050
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-12-13 08:37:58 +01:00
Julien Nabet
88738347f8 cppcheck: incorrectStringBooleanError
Change-Id: I7f4bce8444c6c022d856d20b06de4a4834148ea2
Reviewed-on: https://gerrit.libreoffice.org/64834
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2018-12-10 11:46:41 +01:00
Stephan Bergmann
ab9b67bbb0 Remove obsolete SAL_FALLTHROUGH completely
...after 7ffdd830d5
"HAVE_CPP_ATTRIBUTE_FALLTHROUGH is always true now"

Change-Id: I54e5ff4e036a6bb3e5774d1c0524158aae18e937
Reviewed-on: https://gerrit.libreoffice.org/64800
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-12-08 13:28:16 +01:00
Noel Grandin
e4472d3c13 loplugin:unnecessaryparen include more assignments
Change-Id: I9fb8366634b31230b732dd38a98f800075529714
Reviewed-on: https://gerrit.libreoffice.org/64510
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-12-05 07:49:30 +01:00
Noel Grandin
e909028cab loplugin:unusedenumconstants look through parentheses
Change-Id: I2afdf5a56d827e283dd2362b87446ad7848cb274
Reviewed-on: https://gerrit.libreoffice.org/64452
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-12-04 07:12:19 +01:00
Noel Grandin
93e0622d00 loplugin:intvsfloat get this working reliably
Change-Id: Ifdf1a152f6bc2e2f6edae97a5191120f630f7e49
Reviewed-on: https://gerrit.libreoffice.org/64374
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-12-02 11:46:39 +01:00
Noel Grandin
3b48c94527 loplugin:unusedenumconstants ignore common pattern
Ignore a common pattern that does not introduce any new information,
merely removes information.

Change-Id: I37da352c9295ec12b9dac7aad4b4792a6d726b0d
Reviewed-on: https://gerrit.libreoffice.org/64255
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-30 08:33:15 +01:00
Noel Grandin
933660e591 loplugin:stringconstant look for unnecessary OString constructor use
and tweak the methods in check.hxx to make them more flexible when
called with
   dc.Class(xxx ? "foo" : "bar")

Change-Id: I881fe628f22121ced4d8849715d6b1c92b092da1
Reviewed-on: https://gerrit.libreoffice.org/64207
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-29 09:57:15 +01:00
Stephan Bergmann
d20d442087 Improve wording of loplugin:unoany warnings
...which apparently caused confusion occasionally, cf.
<https://gerrit.libreoffice.org/#/c/58687/5> "Unit test for
0853b05b1fabb231a7d57d811c5a06ee542d3295".

Change-Id: I32f1137bcbb86ffa04bc1a6a58fc93ef69cb3022
Reviewed-on: https://gerrit.libreoffice.org/63874
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-23 14:39:44 +01:00
Stephan Bergmann
f23aa1a51c Bump compiler plugins Clang baseline to 5.0.2
...as discussed at
<https://lists.freedesktop.org/archives/libreoffice/2018-November/081435.html>
"minutes of ESC call ..."

Change-Id: Ia053da171d59747984546f38e19da808825b4f79
Reviewed-on: https://gerrit.libreoffice.org/63832
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-23 08:20:53 +01:00
Noel Grandin
bab2753312 loplugin:unusedenumconstants in EEControlBits
(*) remove effectivly unused enum constants

(*) tweak the plugins heuristics some more to remove false+ in this enum

(*) twweak the python post-processing step to avoid a KeyError

Change-Id: I2943ec94c00f71dcd049f5c9ef33db259c005ba3
Reviewed-on: https://gerrit.libreoffice.org/63709
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-22 07:34:15 +01:00
Noel Grandin
2dbd02b576 loplugin:redundantfcast improvements
check for calls to constructors, and extend the list of types we check
for unnecessary temporary creation

Change-Id: Ia2c1f202b41ed6866779fff5343c821128033eec
Reviewed-on: https://gerrit.libreoffice.org/63472
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-21 12:44:55 +01:00
Noel Grandin
5e2322ec84 loplugin:unusedenumconstants improvements
add some unit tests, and improve the heuristics

Change-Id: I95aa97a87e178ce8d506bd245710d0ae66ad08a4
Reviewed-on: https://gerrit.libreoffice.org/63647
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-20 14:48:27 +01:00
Stephan Bergmann
50e644253f Take array-to-pointer decay into account in loplugin:redundantcast
Change-Id: I3c5bace180605d1a72a74feb1bf9f9b184a16d83
Reviewed-on: https://gerrit.libreoffice.org/63545
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-19 09:25:35 +01:00
Stephan Bergmann
c89a4996b8 Adapt to C++2a char_t
u8 literals incompatibly change their type (as implemented by recent Clang
trunk)

Change-Id: Ia4f7b91f5d86656a056303d2754981ab2093a739
Reviewed-on: https://gerrit.libreoffice.org/63494
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-17 17:17:26 +01:00
Noel Grandin
faa63cd14c new loplugin buriedassign
Change-Id: If6dd8033daf2103a81c3a7c3a44cf1e38d0a3744
Reviewed-on: https://gerrit.libreoffice.org/63466
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-16 14:20:04 +01:00
Noel Grandin
e329049900 loplugin singlevalfields improvement
checking for casting to void* turns out to mask useful stuff, so
remove that and just deal with a few extra false+

Change-Id: Id9700d7ceda90ba8fdb38aa870f13a7ca3acb668
Reviewed-on: https://gerrit.libreoffice.org/63145
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-13 12:27:08 +01:00
Noel Grandin
0b11ce9dd2 loplugin:useuniqueptr extend to checking more local var deletes
Change-Id: I5da0f6ecd2577e92e679ed26dd42629dbac4afd4
Reviewed-on: https://gerrit.libreoffice.org/63132
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-09 06:43:34 +01:00
Noel Grandin
347f347580 new loplugin collapseif
Look for nested if statements with relatively small conditions, where
they can be collapsed into one if statement.

Change-Id: I7d5d4e418d0ce928991a3308fc88969c00c0d0f2
Reviewed-on: https://gerrit.libreoffice.org/62898
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-06 07:45:44 +01:00
Noel Grandin
6ee4375763 new loplugin staticvar
looks for variables that can be declared const and static i.e. they can
be stored in the read-only linker segment and shared between different
processes

Change-Id: I577fb2070604003e56fb44f8a02c9684070311cf
Reviewed-on: https://gerrit.libreoffice.org/61817
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-17 08:25:17 +02:00
Noel Grandin
eaf0c263eb loplugin:staticconstfield improvements
And fix
  ScXMLCachedRowAttrAccess::Cache
which was never setting its mnTab field, and hence would never
be hit.

And fix oox::xls::CellBlockBuffer, which was never setting mnCurrRow.

Change-Id: I2c46aa050b9ebe3c2dc2e52579555f97945dd61c
Reviewed-on: https://gerrit.libreoffice.org/61772
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-15 19:22:21 +02:00
Tamás Zolnai
f4e4231286 Relicense LoopVarTooSmall plugin to use LLVM license
Change-Id: I9e8cf6d7c2474f8c4c624dd9040890997c43f788
Reviewed-on: https://gerrit.libreoffice.org/61789
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2018-10-15 16:07:13 +02:00
Stephan Bergmann
0bf6185516 Fix failure of loplugin:useuniqueptr with older compilers
...where CompilerTest_compilerplugins_clang failed in
compilerplugins/clang/test/useuniqueptr.cxx due to Foo24's

  HTMLAttrs::const_iterator it = m_aSetAttrTab.begin();

and either the old compiler lacked Clang's recent
<https://reviews.llvm.org/D50666> "Fix Stmt::ignoreImplicit" (and the above
initialization expression happens to include a CXXBindTemporaryExpr, at least
with libstdc++), or an even older compiler was used in pre-C++17 mode, so the
above initialization expression happens to include an elidable CXXConstructExpr
copy constructor call.

Change-Id: I757a9ad76829e399b4fe2da1c82863909b8c9657
Reviewed-on: https://gerrit.libreoffice.org/61531
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-10-10 13:46:22 +02:00