Commit Graph

1703 Commits

Author SHA1 Message Date
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
Stephan Bergmann
7ceee0f1ec Extend loplugin:redundantinline to catch inline functions w/o external linkage
...where "inline" (in its meaning of "this function can be defined in multiple
translation units") thus doesn't make much sense.  (As discussed in
compilerplugins/clang/redundantinline.cxx, exempt such "static inline" functions
in include files for now.)

All the rewriting has been done automatically by the plugin, except for one
instance in sw/source/ui/frmdlg/column.cxx that used to involve an #if), plus
some subsequent solenv/clang-format/reformat-formatted-files.

Change-Id: Ib8b996b651aeafc03bbdc8890faa05ed50517224
Reviewed-on: https://gerrit.libreoffice.org/61573
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-10-09 14:47:17 +02:00
Noel Grandin
664db0d945 loplugin:unusedmethods
Change-Id: Icd7a0f9909f36363b307b4fe7ee920183881afbb
Reviewed-on: https://gerrit.libreoffice.org/61576
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-09 14:16:36 +02:00
Noel Grandin
ef0c0dfd77 loplugin:unusedfields
Change-Id: Iacce8e12a85f857192dc0520b795e1990a3612db
Reviewed-on: https://gerrit.libreoffice.org/61575
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-09 12:30:36 +02:00
Stephan Bergmann
5688cd1d9a Fix loplugin:useuniqueptr for libc++ (macOS)
...after 05a337e297 "loplugin:useuniqueptr look
for deleting in loops with iterators", where it didn't emit the warning for
Foo24 in compilerplugins/clang/test/useuniqueptr.cxx during
CompilerTest_compilerplugins_clang, because in the initialization of

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

the HTMLAttrs::const_iterator CXXConstructExpr happens to have a second,
defaulted argument.

Change-Id: I882a6dfb5cab1b147f790072f2545b13172c0f9a
Reviewed-on: https://gerrit.libreoffice.org/61530
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-10-08 16:58:44 +02:00
Miklos Vajna
e056e30f82 compilerplugins: the useuniqueptr clang plugin test fails on 5.0.1
I'm not sure what is the first version that passes it, let's go with 6.0
for now.

Change-Id: I7a150fbc2a722a6a47d91de4b00893303add5cc8
2018-10-08 12:31:17 +02:00
Andrea Gelmini
54d82085cc Fix typo
Change-Id: I822fa325d37955583a21e4d7ce2e79a4d5b02fc5
Reviewed-on: https://gerrit.libreoffice.org/61462
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2018-10-06 12:15:01 +02:00
Noel Grandin
05a337e297 loplugin:useuniqueptr look for deleting in loops with iterators
Change-Id: I0e5bf671ee11265c0afa8770430ec9e064e05fe3
Reviewed-on: https://gerrit.libreoffice.org/61402
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-05 16:18:57 +02:00
Noel Grandin
6f28db10d7 loplugin:unusedmethods
Change-Id: I9e583df920657ab401162db79decb192c4f69f90
Reviewed-on: https://gerrit.libreoffice.org/61283
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-03 12:09:21 +02:00
Noel Grandin
4969f4c0d3 loplugin:constfields in sw
Change-Id: I1eb6583bb9ec815bc0564b0d7c676f5b1fb9045f
Reviewed-on: https://gerrit.libreoffice.org/61177
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-03 11:56:43 +02:00
Noel Grandin
487fc22690 loplugin:unusedfields
Change-Id: I3d2cdd80b542dbdbd29971ef837111191809f081
Reviewed-on: https://gerrit.libreoffice.org/61282
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-03 11:03:31 +02:00
Noel Grandin
dbeb289888 loplugin:unusedmethods
Change-Id: I7db0c27ff2213210ed4b46ebbadc1a2f74a18257
Reviewed-on: https://gerrit.libreoffice.org/61249
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-03 08:28:10 +02:00
Noel Grandin
be98dffedd loplugin:unusedfields
Change-Id: Idf6f7f2946eecada64d2a586194533840ec8cc63
Reviewed-on: https://gerrit.libreoffice.org/61248
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-03 08:26:20 +02:00
Stephan Bergmann
b0eab4b2d2 Add loplugin:includeform documentation
Change-Id: I5a8c6ab0a967d9da2e1764301cd54f87f467a653
Reviewed-on: https://gerrit.libreoffice.org/61176
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-10-01 16:15:11 +02:00
Jan-Marek Glogowski
1f2f53501c implicitboolconversion: ignore quint64 bitfield
Change-Id: I97380455b9f526b75c7d3855d188d2f659035ba2
Reviewed-on: https://gerrit.libreoffice.org/61170
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-10-01 10:57:27 +02:00
Noel Grandin
2fbb97367a loplugin:unusedmethods
Change-Id: I5f9ef043d76c55f2c761fd08a2bc1dae66b675c8
Reviewed-on: https://gerrit.libreoffice.org/61073
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-28 13:31:49 +02:00
Andrea Gelmini
a8cd67e269 Fix typo
Change-Id: I3473cb5a565aba822428178030572325425c6a13
Reviewed-on: https://gerrit.libreoffice.org/61030
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2018-09-28 09:26:22 +02:00
Noel Grandin
a6c7c2fe1b loplugin:unusedfields
Change-Id: I355fad84ed8765e8eb3fadb7c239b3b902ec1747
Reviewed-on: https://gerrit.libreoffice.org/61059
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-28 09:06:48 +02:00
Andrea Gelmini
2a7fe9b08d Fix E_SUCCEDED -> E_SUCCEEDED
It passed "make check" on Linux.

Change-Id: I96b34c818f6d4170c110ecd1fb93af79c3279e57
Reviewed-on: https://gerrit.libreoffice.org/61028
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2018-09-28 08:24:01 +02:00
Noel Grandin
1534025a03 loplugin:methodcycles more graph theory for the win
implemeent a reduction approach, which is good at finding virtual
methods that only themselves or their virtual partners.

The accessibility GetVisArea stuff is dead since
    commit 891e41fac8
    Date:   Wed Apr 4 11:23:22 2018 +0200
    dead code in AccessibleTextHelper_Impl::UpdateVisibleChildren

Change-Id: I78d9d8bca585ecec8394f2c3fe2baa93db0e58f5
Reviewed-on: https://gerrit.libreoffice.org/60912
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-27 11:48:46 +02:00
Stephan Bergmann
928b1b04ad loplugin:external (clang-cl)
Including:

* expanding STDAPI to its definition (as per
  <https://msdn.microsoft.com/library/ms686631(vs.85).aspx> "STDAPI"), to add
  __declspec(dllexport) into its middle, in
  extensions/source/activex/so_activex.cxx; as discussed in the comments at
  <https://gerrit.libreoffice.org/#/c/60691/> "Get rid of Windows .def files in
  setup_native, use __declspec(dllexport)", having a function both listed in a
  .def file EXPORTS and marking it dllexport is OK, and the latter helps the
  heuristics of loplugin:external; however, the relevant functions in
  extensions/source/activex/so_activex.cxx probably don't even need to be
  exported in the first place?

* follow-up loplugin:salcall in sal/osl/w32/file-impl.hxx

Change-Id: Ida6e17eba19cfa3d7e5c72dda57409005c0a0191
Reviewed-on: https://gerrit.libreoffice.org/60938
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-24 17:22:05 +02:00
Noel Grandin
1aa37aa6be loplugin:unusedmethods
Change-Id: I9dac9260af9955dc4a66b34c33265c6e36094322
Reviewed-on: https://gerrit.libreoffice.org/60911
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-23 12:24:01 +02:00
Stephan Bergmann
8b1501d80d Always disable loplugin:expressionalwayszero, to avoid false positives
bdade7e3fc "tdf#105444 DOCX import: don't put
extra paragraphs in comments" caused

> /home/sbergman/lo2/core/writerfilter/source/dmapper/DomainMapper_Impl.cxx:441:22: error: expression always evaluates to zero, lhs=0 rhs=unknown [loplugin:expressionalwayszero]
>                     (sizeof(SAL_NEWLINE_STRING)-1 == 2 && xCursor->getString() == "\n"))
>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

now with sufficiently new Clang, and the code looks reasonable, and there's no
apparent way to avoid such false positives in the plugin.  (It could check for a
sub-expression of the problematic expression being an object-like macro, but
SAL_NEWLINE_STRING could just as well be a variable instead of a macro.  That
variable would need to be defined in some #if to have different values on
different platforms, so the plugin could theoretically check for such
conditional inclusion, but it's not clear whether that's worth it and would even
be a useful heuristic to not produce neither too many false positives nor too
many false negatives.)  So just disable the plugin for good.

Change-Id: I85dc8573735ccac4e19be20ab7443cbaa85a3164
Reviewed-on: https://gerrit.libreoffice.org/60907
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-22 23:59:53 +02:00
Noel Grandin
4c945b22fc new loplugin:methodcycles
look for closed cycles of methods i.e. unused code that would not
otherwise be found by the unusedmethods loplugin

Change-Id: I3fb052132d97aabca573bb8e9fc424201b1e2042
Reviewed-on: https://gerrit.libreoffice.org/60875
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-21 18:44:29 +02:00
Stephan Bergmann
92d4e9304c Replace SAL_FINAL with final in internal code
Change-Id: Ib0d3324d7021ba1a8ff9779807d0a900be5e6226
Reviewed-on: https://gerrit.libreoffice.org/60802
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-20 15:53:50 +02:00
Noel Grandin
d7f2c36d25 loplugin:unusedmethods
Change-Id: I5f63ac44654ed3fc658e72e0d1148a5a22decc47
Reviewed-on: https://gerrit.libreoffice.org/60662
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-18 15:22:40 +02:00
Noel Grandin
5d86154f49 loplugin:unusedfields improve search for unused collection fields
look for collection-like fields that are never added to, and are
therefore effectively unused

Change-Id: Id52c5500ea5e3d2436fb5915aebb86278bf2d925
Reviewed-on: https://gerrit.libreoffice.org/60661
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-18 15:19:04 +02:00
Noel Grandin
455ac9fb7a loplugin:useuniqueptr check more local variables
Change-Id: I8387731747ee6eb7d74037c0eff7fc9ac0b884c8
Reviewed-on: https://gerrit.libreoffice.org/60619
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-18 09:07:56 +02:00
Noel Grandin
05db125c57 loplugin:staticconstfield improvements
Change-Id: Ia0a19736dfd4500bb17b04c072710f8ee8744031
Reviewed-on: https://gerrit.libreoffice.org/60526
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-17 10:52:39 +02:00
Stephan Bergmann
206b5b2661 New loplugin:external
...warning about (for now only) functions and variables with external linkage
that likely don't need it.

The problems with moving entities into unnamed namespacs and breaking ADL
(as alluded to in comments in compilerplugins/clang/external.cxx) are
illustrated by the fact that while

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

returns 1, both moving just the struct S2 into an nunnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    namespace { struct S2: S1 { int f() { return 1; } }; }
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

as well as moving just the function f overload into an unnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    namespace { int f(S2 s) { return s.f(); } }
  }
  int main() { return f(N::S2()); }

would each change the program to return 0 instead.

Change-Id: I4d09f7ac5e8f9bcd6e6bde4712608444b642265c
Reviewed-on: https://gerrit.libreoffice.org/60539
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-17 09:05:38 +02:00
Noel Grandin
7168fe32c9 rename conststringfield loplugin to staticconstfield
in preparation for making it more general

Change-Id: I2fc8d0f99140dc7ef72341f8cbf28d6536ebd61f
Reviewed-on: https://gerrit.libreoffice.org/60525
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-16 12:01:59 +02:00
Stephan Bergmann
e49a3970f8 Check that loplugin:unreffun warns for explicitly "extern" functions
Change-Id: Ic43f007af4480b358916c2b27796a9b248ea9eb7
Reviewed-on: https://gerrit.libreoffice.org/60496
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-14 16:39:20 +02:00
Stephan Bergmann
c62d02bcb9 Improve loplugin:simplifyconstruct warnings
Change-Id: I0a64d0eb9938d5a99416dbe4078ba4c05e5d588b
Reviewed-on: https://gerrit.libreoffice.org/60465
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-14 10:39:50 +02:00
Noel Grandin
b74db41383 loplugin:simplifyconstruct exclude std::unique_ptr with custom deleter
Change-Id: I8f4ba883747a2aace88786ef807fd7c338bef5da
2018-09-13 13:31:41 +02:00
Noel Grandin
61e94390a3 new loplugin simplifyconstruct
no need to init smart pointers with nullptr, they all have default
constructors that do this already

Change-Id: Ief20c060daa0def8c1aa82f1cf8dc4bc696761e9
Reviewed-on: https://gerrit.libreoffice.org/59818
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-13 11:15:33 +02:00
Noel Grandin
8c29b0837d new loplugin:constfields
look for fields which are only assigned to in the constructor, so they
can be made const

Change-Id: I0b76817c2181227b04f6a29d6a808f5e31999765
Reviewed-on: https://gerrit.libreoffice.org/60393
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-13 08:30:11 +02:00
Noel Grandin
569f7a4ade loplugin:unusedmethods
Change-Id: I0f96c41ab61bd4bfaf6c36d78d0a2ca768da0032
Reviewed-on: https://gerrit.libreoffice.org/60314
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-12 13:23:27 +02:00
Noel Grandin
40069adbc2 loplugin:unusedfields
Change-Id: Ic7871f3a40668ba73aa0f0067a45455920d55890
Reviewed-on: https://gerrit.libreoffice.org/60313
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-11 18:18:12 +02:00
Noel Grandin
7430dfe2a4 loplugin:unusedmethods
Change-Id: I34009aabf0befb346470b5c0d96ad8fc476b7c4e
Reviewed-on: https://gerrit.libreoffice.org/60300
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-11 14:01:00 +02:00
Noel Grandin
0e8e5c196b loplugin:unusedfields
Change-Id: I876183559a7d9f1e6d914fbf37d7ffe91459144e
Reviewed-on: https://gerrit.libreoffice.org/60278
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-11 09:39:44 +02:00
Noel Grandin
2da435922f loplugin:constantparam
Change-Id: Ia11bf93768d5f722b7fe62df15f24809cb7e7f04
Reviewed-on: https://gerrit.libreoffice.org/60280
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-11 09:15:42 +02:00
Noel Grandin
b40e57f403 fix loplugin:unusedmethods
revert the part of
    commit 9f4d23c151
    Date:   Mon Aug 13 17:24:26 2018 +0200
    filter out some of the AST in the plugins
that applied to this plugin. Turns out it really needs to see __all__
the code in order to produce good results.

Change-Id: If580a701049d2570f2a833327b2189641090079b
Reviewed-on: https://gerrit.libreoffice.org/60279
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-11 08:18:16 +02:00
Noel Grandin
9a9d407977 prevent crashes when running the global-analysis plugins
Change-Id: Ib50583289afd6212d5d5aedd3d6b7ede75902052
Reviewed-on: https://gerrit.libreoffice.org/60277
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-11 08:17:31 +02:00
Arkadiy Illarionov
97b6fd8e9e Replace find_if with proper quantifier algorithms
Missed in 085269d25a

Change-Id: I3cfab57232908b48d090658e0fbc948d62b3fc6f
Reviewed-on: https://gerrit.libreoffice.org/60180
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-08 14:46:08 +02:00
Caolán McNamara
a2304f62e9 weld writer page style dialog and SvxBorderBackgroundDlg
writer, format page is complete

Change-Id: I09f6e4354461c4374cdb0d0e0754dfee35415b45
Reviewed-on: https://gerrit.libreoffice.org/60058
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2018-09-07 14:42:31 +02:00
Noel Grandin
651a2dee1c loplugin:useuniqueptr update exclusions
Change-Id: I9c741dbaba772550b4d68406fff50d8b0ac60874
Reviewed-on: https://gerrit.libreoffice.org/59923
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-03 11:03:30 +02:00
Andrea Gelmini
59a4804ce4 Fix typos
Change-Id: Ia658776bce8744e7b771559ca12b94a20923fc52
Reviewed-on: https://gerrit.libreoffice.org/59782
Tested-by: Jenkins
Reviewed-by: Jens Carl <j.carl43@gmx.de>
2018-08-30 18:36:37 +02:00
Noel Grandin
4c91b89d8c new loplugin:oustringbuffer
look for places where we are appending the temporary result of adding
strings together, to an OUStringBuffer, where we could rather call
append repeatedly and avoid the temporary creation

Change-Id: I481435124291ac7fb54b91a78344a9fe5b379a82
Reviewed-on: https://gerrit.libreoffice.org/59708
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-29 09:05:18 +02:00
Noel Grandin
1fd27a7931 filter out AST in more plugins
I seem to have missed quite a few in

    commit 9f4d23c151
    filter out some of the AST in the plugins

This nets me another 14% improvement

Change-Id: I39b980b49ced560f768045dbedd3ddfef29306c1
Reviewed-on: https://gerrit.libreoffice.org/59501
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-23 16:34:48 +02:00
Stephan Bergmann
b3f4d69d31 Avoid warnings about unused private fields
Change-Id: If8fa47120f8dd7453a30f28ca9f726cbcbb80dc2
2018-08-23 08:50:43 +02:00