Commit Graph

1496 Commits

Author SHA1 Message Date
Noel Grandin
13341ffa49 teach unnecessaryparen plugin about other kinds of statements
i.e. do / while / switch

Change-Id: Id0985015cc425557f9984734701d56466f8a6088
Reviewed-on: https://gerrit.libreoffice.org/39601
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-06 08:31:52 +02:00
Noel Grandin
a1ead1a028 loplugin unnecessaryparan improvements
Change-Id: I73e945d6ec53537a0da45f6b6291018c7f251a7e
Reviewed-on: https://gerrit.libreoffice.org/39587
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-06 08:31:30 +02:00
Noel Grandin
4b2262ab5b new loplugin unnecessaryparen
Change-Id: Ic883a07b30069ca6342d7521c8ad890f4326f0ec
Reviewed-on: https://gerrit.libreoffice.org/39549
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-05 11:08:48 +02:00
Noel Grandin
6e3a563186 loplugin:unusedfields various
Change-Id: Ia7bcf2471381aa6a2768ea795fe6572e38209100
2017-07-05 08:37:05 +02:00
Noel Grandin
2b487c2a13 loplugin:unusedfields connectivity
Change-Id: I056b36249803982e451b887cc73b49a851144b7e
Reviewed-on: https://gerrit.libreoffice.org/39498
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-05 08:33:54 +02:00
Noel Grandin
eeb1030c64 loplugin:unusedfields in cui..idl
Change-Id: Icb393cc0b2f79ded154e186ab6975b95e5126903
Reviewed-on: https://gerrit.libreoffice.org/39496
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 14:51:07 +02:00
Stephan Bergmann
3822597b21 typo in comment
Change-Id: I816f2dad87d798296e60a5eb8842a147f504b90b
2017-07-04 12:15:50 +02:00
Noel Grandin
ea1839853f loplugin:unusedfields in editeng
Change-Id: I9806d87028a11a8103c35004c87b5098ca591409
Reviewed-on: https://gerrit.libreoffice.org/39495
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 12:06:47 +02:00
Noel Grandin
469076317d loplugin:unusedfields l10ntools..rsc
Change-Id: I78785eeab436910c9e8733924a7c43fa998ba36f
Reviewed-on: https://gerrit.libreoffice.org/39491
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 11:26:09 +02:00
Noel Grandin
8237a77245 loplugin:unusedfields in formula
Change-Id: I5d8fe8869087efda68d040448b2d9e0e7e5611f6
Reviewed-on: https://gerrit.libreoffice.org/39493
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 11:05:28 +02:00
Noel Grandin
2b24fba09c loplugin:unusedfields in framework
Change-Id: Ibb602e037bcee518c31dfe9734a5c5773cff23ab
Reviewed-on: https://gerrit.libreoffice.org/39492
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 10:51:46 +02:00
Noel Grandin
2a1a960339 loplugin:unusedfields in sd
Change-Id: I42def3dc21ae1a18e1c98d1aeeff4ed4425e941a
Reviewed-on: https://gerrit.libreoffice.org/39479
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 08:36:50 +02:00
Noel Grandin
fb0644e8f0 loplugin:unusedfields in sfx2
Change-Id: I9f57545ca4ee5159a095f9b35267d298ccc7fb4e
Reviewed-on: https://gerrit.libreoffice.org/39476
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 08:36:11 +02:00
Noel Grandin
b3499a00fc loplugin:unusedfields
Change-Id: I6bf3de7ba6e6bff2fd607156a0dcdd554887e491
Reviewed-on: https://gerrit.libreoffice.org/39475
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-04 08:35:48 +02:00
Stephan Bergmann
dfc0dc4801 loplugin:casttovoid: fix containsPreprocessingConditionalInclusion()
...and re-enable plugin

Change-Id: I0b42cfc0f0b45711e714e6661ae9dd39f05f8960
2017-07-04 08:15:08 +02:00
Noel Grandin
e037381f85 loplugin:unusedfields in slideshow..svtools
Change-Id: I74d5a4b8cfc4b18267f99648a3112b163c91fd8c
Reviewed-on: https://gerrit.libreoffice.org/39474
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-03 16:03:34 +02:00
Stephan Bergmann
decfa1ff87 Disable loplugin:casttovoid for now
I'd accidentally developed it against a Clang built without
LLVM_ENABLE_ASSERTIONS=ON, so only saw issues with
containsPreprocessingConditionalInclusion() now.

Change-Id: I5da6775a06de748e78b34a42f63b0543c3893124
2017-07-03 13:58:53 +02:00
Stephan Bergmann
65d6c64259 loplugin:casttovoid
Change-Id: I427b15b35ef6e7c803cb8a00c961d35175ae8cb2
2017-07-03 12:34:38 +02:00
Stephan Bergmann
33ee8e6129 Work around bug in Clang 3.8
...that causes

> clang/lib/AST/Type.cpp:1878: bool clang::Type::isConstantSizeType() const: Assertion `!isDependentType() && "This doesn't make sense for dependent types"' failed.

compilation failure in PCodeBufferWalker in basic/source/comp/codegen.cxx

>    static T readParam( sal_uInt8 const *& pCode )
>    {
>        short nBytes = sizeof( T );
>        T nOp1=0;
>        for ( int i=0; i<nBytes; ++i )
>            nOp1 |= *pCode++ << ( i * 8);
>        return nOp1;
>    }

with loplugin:oncevar.

Change-Id: I25417076549ea538adf013282f3657e0d642d776
2017-07-03 10:33:13 +02:00
Noel Grandin
a5c200bddd loplugin:unusedfields in svx
Change-Id: I027b70ee92ab07eb68452457c3ee45de3ad22c8b
Reviewed-on: https://gerrit.libreoffice.org/39412
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-03 10:19:36 +02:00
Noel Grandin
09a4d2faa4 loplugin:unusedfields in sw
Change-Id: I807f93757bfddf17f71568f1e3c174229f169f18
Reviewed-on: https://gerrit.libreoffice.org/39409
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-03 10:19:03 +02:00
Noel Grandin
979d58c9a9 loplugin:unusedfields in toolkit..xmloff
Change-Id: I4964ff97e0a1735dc08c6ad204cae0b08e9ffc2c
Reviewed-on: https://gerrit.libreoffice.org/39406
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-30 19:50:30 +02:00
Stephan Bergmann
ce1613ae0d Actually print parent name
Change-Id: Iba9bacc0ecaf5288f5c53f6fa73340504c646b4f
2017-06-30 14:04:42 +02:00
Stephan Bergmann
09031ef2fe Avoid getQualifiedNameAsString
Change-Id: I448bfd63f1a2fb9cac3366146b10ff6a465e6db7
2017-06-30 11:16:03 +02:00
Noel Grandin
acd8f0c344 fix some crashes in unusedfields plugin
for some reason the insideMoveOrCopyDecl pointer to MethodDecl becomes
bad during AST traversal, but the pointers to RecordDecl seem stable?

Change-Id: Ida939f5ca4780e674b245411f7395f147258544e
2017-06-29 13:52:44 +02:00
Noel Grandin
4cc2fc6cef unusedfields loplugin writeonly analysis improvements
(1) ignore reads inside copy/move constructors/operator=
(2) fix false+ when assigning to array field
(3) ignore reference ("&") fields

Change-Id: I69a1a1c567a0b28a783e605982e5150811b6cc4a
2017-06-29 11:00:57 +02:00
Noel Grandin
497e40ad03 improve refcounting loplugin
to find ref-counted classes being managed via other smart pointer
classes.
Hopefully prevent needing fixes like
642ae256ea
"ChangedUIEventListener is refcounted, mustn't be helt by unique_ptr"

Change-Id: I6b0c5f8f87ce3546a8a1104ce1000470c09459bd
Reviewed-on: https://gerrit.libreoffice.org/39378
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-29 09:35:30 +02:00
Noel Grandin
71112060e0 loplugin:oncevar various
Change-Id: I8b82d46d4688b1a59d6fe1b05da7d5c8dfc13ca6
Reviewed-on: https://gerrit.libreoffice.org/38766
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-29 08:18:35 +02:00
Stephan Bergmann
faa7491131 Fix loplugin:vclwidgets' disposeOnce check
Found when trying to temporarily add a SAL_DEBUG to (otherwise empty)
~NotebookbarTabControl (sfx2/source/notebookbar/NotebookbarTabControl).
2017-06-26 16:37:20 +02:00
Noel Grandin
742f030d67 update constantfunction loplugin
didn't find anything useful, so just updating the exclusion lists

Change-Id: I66d37aee185290f454e5ac0baeafd1f67bfaf106
Reviewed-on: https://gerrit.libreoffice.org/39254
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-26 11:00:32 +02:00
Jochen Nitschke
97ee2bbd40 extensions: remove COMPMOD preprocessor defines
COMPMOD_RESPREFIX=abp was unused ever since initial commit in 2001.

COMPMOD_NAMESPACE was used to set the namespace name qualifier of
the helper in componentmodule.hxx to the extension's namespace name.

I don't see why this is necessary as the helper is always compiled in
a separate extension library.

Change-Id: I287607008db3dc0ebc32731536747a921c91807d
Reviewed-on: https://gerrit.libreoffice.org/39184
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-26 09:05:43 +02:00
Stephan Bergmann
e9ad1b4f2f std::string -> StringRef
Change-Id: I06145822290ae4b3690a792eb4d2ad79437fd9cc
2017-06-23 15:18:21 +02:00
Tor Lillqvist
77da7b934d Fix compilation with Clang 3.9.1
Change-Id: I6e96064a001fd511864665fe0ef8b60d45462c12
2017-06-21 17:00:47 +03:00
Noel Grandin
742c0838f2 loplugin:unusedfields in svx part1
Change-Id: I6621e0dda5a5dc3e68c7b1613975c075e2879912
Reviewed-on: https://gerrit.libreoffice.org/39006
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-21 08:42:41 +02:00
Stephan Bergmann
5f63d2c599 -Werror=unused-function
Change-Id: Iecc7d68ad18e90bf84d358af92194c230efc2671
2017-06-20 14:25:08 +02:00
Noel Grandin
6a24b52b82 fix for older clang in loplugins
since commit 03ee996717
"loplugin:unusedfields fix more false +"

Change-Id: Ief935fea8c554707db38b4ede4fab2ec1adca997
2017-06-20 12:03:37 +02:00
Noel Grandin
4c0198b02c reformat some loplugin code
to match our more normal conventions.

Also drop the 'using std' and some other cruft

Change-Id: I02ef81c5427188bc03a20b157a57a900a9d7bf0d
2017-06-20 10:26:46 +02:00
Noel Grandin
03ee996717 loplugin:unusedfields fix more false +
deal with fields assigned to local variables, and some general cleanup

Change-Id: I894c74a01e9e28935ecd84308c2e92b080afafc6
2017-06-20 10:02:32 +02:00
Noel Grandin
9d9d024ffb loplugin:unusedfields fix some more false positives
in the write-only analysis

Change-Id: Ic570416e855b8ec38d54f6f6f1adef4819ea53ee
2017-06-20 10:01:48 +02:00
Noel Grandin
9c2b43e86f improve oncevar loplugin
we look for any kind of scalar variable now that deserves to be inlined,
and we check for variables that cannot be inlined because they are being
passed by reference, or modified, or have their address taken

Change-Id: Ia744a180e91d1516140a1555d4514f6fa4de1c0b
Reviewed-on: https://gerrit.libreoffice.org/38966
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-20 07:49:45 +02:00
Noel Grandin
3b60f59bc5 loplugin:unusedfields fix false positive
When the field in question is read from inside a constructor
initializer.

In the process, create some needed infrastructure in the plugin classes.

Change-Id: I2f440efa6912801a236727c9fe3180404616958c
Reviewed-on: https://gerrit.libreoffice.org/38960
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-20 07:49:27 +02:00
Noel Grandin
45c06838e9 only unit-test one loplugin at a time
tell the plugin code when we are unit-testing it, so we can suppress all
the warnings except for the plugin we are currently testing

Change-Id: I240c8e37eba90c219e53c29531a3a43bc841a1c8
2017-06-19 11:34:15 +02:00
Stephan Bergmann
1e3a00f0c7 Make SfxItemSet ranges correct by construction: Fix static cases
...with the aid of an extended compilerplugins/clang/store/sfxitemsetrewrite.cxx
(which in turn needed a small addition to compilerplugins/clang/check.hxx).

Enable svl::detail::validGap check for the static case, but keep it disabled for
now for the dynamic case.

Change-Id: I4846ba8e99aff94a86518e2cb5044e575093386e
2017-06-19 09:38:05 +02:00
Stephan Bergmann
13bb5a4b09 Make SfxItemSet ranges correct by construction
This is a follow-up to 45a7f5b62d "Keep WID ranges
sorted, and join adjacent ones".  While SfxItemSet::MergeRange relies on the
m_pWhichRanges being sorted (and, under DBG_UTIL, asserts if they are not), the
various SfxItemSet constructors curiously only check (via assert or DBG_ASSERT)
that each individual range has an upper bound not smaller than its lower bound.
Arguably, all SfxItemSet instances should fulfill the stronger guarantees
required and checked by MergeRange.

And in many cases the ranges are statically known, so that the checking can
happen at compile time.  Therefore, replace the two SfxItemSet ctors taking
explicit ranges with two other ctors that actually do proper checking.  The
(templated) overload taking an svl::Items struct should be used in all cases
where the range values are statically known at compile time, while the overload
taking a std::initializer_list<Pair> is for the remaining cases (that can only
do runtime checking via assert).  Most of those latter cases are simple cases
with a single range covering a single item, but a few are more complex.

(At least some of the uses of the existing SfxItemSet overload taking a

  const sal_uInt16* pWhichPairTable

can probably also be strengthened, but that is left for another day.)

This commit is the first in a series of two.  Apart from the manual changes to
compilerplugins/clang/store/sfxitemsetrewrite.cxx, include/svl/itemset.hxx, and
svl/source/items/itemset.cxx, it only consists of automatic rewriting of the
relevant SfxItemSet ctor calls (plus a few required manual fixes, see next).
But it does not yet check that the individual ranges are properly sorted (see
the TODO in svl::detail::validGap).  That check will be enabled, and the ensuing
manual fixes will be made in a follow-up commit, to reduce the likelyhood of
accidents.

There were three cases of necessary manual intervention:

* sw/source/core/unocore/unostyle.cxx uses eAtr of enum type RES_FRMATR in
braced-init-list syntax now, so needs explicit narrowing conversion to
sal_uInt16.

* In sw/source/uibase/uiview/formatclipboard.cxx, the trailiing comma in the
definition of macro FORMAT_PAINTBRUSH_FRAME_IDS needed to be removed manually.

* In svx/source/svdraw/svdoashp.cxx, svx/source/svdraw/svdotext.cxx,
sw/source/uibase/app/docstyle.cxx, sw/source/uibase/shells/frmsh.cxx,
sw/source/uibase/shells/grfsh.cxx, and sw/source/uibase/shells/textsh1.cxx,
some comments had to be put back (see "TODO: the replaced range can contain
relevant comments" in compilerplugins/clang/store/sfxitemsetrewrite.cxx).

A few uses of the variadic form erroneously used nullptr instead of 0 for
termination.  But this should have been harmless even if promoted std::nullptr_t
is larger than promoted sal_uInt16, assuming that the part of the nullptr value
that was interpreted as sal_uInt16/promoted int was all-zero bits.  Similarly,
some uses made the harmless error of using 0L instead of 0.

Change-Id: I2afea97282803cb311b9321a99bb627520ef5e35
Reviewed-on: https://gerrit.libreoffice.org/38861
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2017-06-16 17:28:41 +02:00
Noel Grandin
2c83c40b43 improve unusedfields loplugin
to ignore assignments when doing writeonly analysis

Change-Id: I9eb6f2594003a610582dbc20acb7ccf14ef72c6c
2017-06-15 11:36:05 +02:00
Stephan Bergmann
423dacde87 Generalize loplugin:stringcopy to loplugin:redundantcopy
(such redundant std::unique_ptr copies could happen when changing parts of the
code base to make use of std::unique_ptr individually)

Change-Id: Ib48a45a212f9426a775c7f379bc5d3c92230218a
2017-06-13 17:00:30 +02:00
Stephan Bergmann
bd5a895c2b DbgCheckItemSet is gone
...since 87c9465262 "Bin unused function
DbgCheckItemSet"

Change-Id: I109598dc5e087697d77b96a0ba2fb178d47b3aa6
2017-06-08 16:40:12 +02:00
Stephan Bergmann
fee8afc229 getBody() can be null for a defaulted dtor
Not sure why that started to pop up only now, maybe something changed with
recent Clang trunk.

Change-Id: Ib6587b66afbf3e43d92c78432c0bfd61c74ba6c5
2017-06-06 09:23:17 +02:00
Stephan Bergmann
690f2f5c46 Avoid loplugin:unreffun
Change-Id: I75ea46f257046bb42b2bfad3a5bd4450868e0d69
2017-06-06 08:04:06 +02:00
Stephan Bergmann
2725f88465 Improved loplugin:cstylecast to reference types
Change-Id: Ie95ab6d588cfe40cc9748ce526b80d06fe825da5
2017-06-05 21:18:14 +02:00