Commit Graph

70 Commits

Author SHA1 Message Date
Luboš Luňák
bef96f7a7b better name for a function in compilerplugins
The function is not just about a spelling location.

Change-Id: I96e9e9ef7e27a9763397b4b86473c1c30d0e3eeb
Reviewed-on: https://gerrit.libreoffice.org/80381
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2019-10-08 20:46:36 +02:00
Luboš Luňák
c8bf651fb9 do not use compiler.getSourceManager().getFilename()
This is a continuation of ff002524c1.
When compiling with icecream, its -frewrite-includes merges
all #include's into one .cxx file and marks them with with line
markers. But SourceManager::getFilename() doesn't take those
into account and so it reports all of those as <stdin>.
So use getFileNameOfSpellingLoc(), which explicitly handles this
case.
And we should probably never ever use SourceManager::getFilename().

Change-Id: Ia194c2e041578e1e199aee2df2f885922ef7e31a
Reviewed-on: https://gerrit.libreoffice.org/80326
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2019-10-07 15:21:50 +02:00
Andrea Gelmini
22ef2a15bb Fixing "...."
Change-Id: Id005a7531d546dd43de13b49bcb3e93081c5ad8d
Reviewed-on: https://gerrit.libreoffice.org/78679
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-09-06 09:15:58 +02:00
Noel Grandin
8303e7ed66 loplugin:unusedfields improvements
tighten up the only calling write-only methods part of the analysis

Change-Id: I5bc6fdf0ce51940653317e8a48c5241705c90d4c
Reviewed-on: https://gerrit.libreoffice.org/74022
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-06-14 11:37:35 +02: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
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
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
Noel Grandin
75dd5d2e73 add EvaluateAsInt compat function for latest clang
the old EvaluateAsInt method has been dropped as from current clang

Change-Id: Ie30d1547ad8de777badff4b380d2fc9fb261e8fe
Reviewed-on: https://gerrit.libreoffice.org/64107
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-27 17:16:05 +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
fd56d5fd40 loplugin:unusedfields improvemements
treat fields touched in operator== as not being important, which
finds some more stuff (but also adds some false+)

Change-Id: I3f5d504d7dec7945a917afbcd58c92df74f03645
Reviewed-on: https://gerrit.libreoffice.org/62020
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-22 12:47:48 +02:00
Noel Grandin
16690220ed loplugin:singlevalfields
tighten up the handling of binary operators

Change-Id: I262ec57bf7142fa094d240738150a94d83fd15ee
Reviewed-on: https://gerrit.libreoffice.org/61777
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-17 08:25:06 +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
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
9f4d23c151 filter out some of the AST in the plugins
by checking if the current namespace decl is in our code, so we have to
scan less stuff, which results in a 10% perf improvement for me

Change-Id: Idf0e30d57b6d0dcd13daa9ed679c28b9d233d387
Reviewed-on: https://gerrit.libreoffice.org/58942
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-14 13:02:14 +02:00
Stephan Bergmann
3cc5149a84 Avoid -Werror=deprecated-declarations with recent Clang trunk
...which first added alternative names to and then deprecated getLocBegin/End

Change-Id: Iaefb8ce259057abfa6cd20f0b63c0ef2949a96b2
Reviewed-on: https://gerrit.libreoffice.org/58820
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-10 15:14:03 +02:00
Noel Grandin
12dce07aec loplugin:unusedfields - look for fields that can be const, in comphelper
idea from tml.

Extend the unusedfields plugin to find fields that are only assigned in
the constructor.

Change-Id: I258d3581afbe651d53ce730c9ba27a4598cd9248
Reviewed-on: https://gerrit.libreoffice.org/57733
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-07-20 14:12:57 +02:00
Noel Grandin
d98f1e4e03 loplugin:unusedfields improve checking for write-only fields
we trade off a little accuracy for finding more possible write-only
fields.

Change-Id: I9f7edba99481fe4ded0a9d8e45e911b0ee99d269
Reviewed-on: https://gerrit.libreoffice.org/56715
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-07-02 08:47:48 +02:00
Noel Grandin
6ac83797e0 improve unusedfields loplugin to find constructor-only fields
ie. fields that are only touched in the constructor

Change-Id: Ia714cbfed9710e47e69ca9f0eb0eac4f7e8b8a86
Reviewed-on: https://gerrit.libreoffice.org/54412
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-05-19 21:32:11 +02:00
Noel Grandin
64a5d65f4c put the loplugin output files in the workdir
so that the next time I accidentally leave one turned on, and commit it,
the buildbots will clean up naturally the next time they run 'make
clean'

Change-Id: Ia09dea9c272c322c7e2773c5458cb54aceb50dd1
2018-04-10 15:54:24 +02:00
Noel Grandin
9e6ee59a0f darn, unusedfields loplugin was left enabled
Change-Id: I343262e0c61e9ecde5395f13732c212197e7fd03
2018-04-10 15:14:33 +02:00
Noel Grandin
e9586cf0b5 loplugin:unusedfield improvements
improve the read-only check to ignore reads from fields that are guarded
by a boolean check, something like:
   if (field)
       field.foo();
this produces some false positives at the moment because I'm not
correctly handling the else block, but also some useful new dead code.

Change-Id: Id21fa1a56c171d09d979769b978b6eef14e8b695
Reviewed-on: https://gerrit.libreoffice.org/52664
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-04-10 10:38:23 +02:00
Stephan Bergmann
17b9ef3858 Don't build off-by-default loplugin:unusedfields on Windows for now
...due to missing sys/file.h

Change-Id: I7cfd64c5355d9fdbb85320f876c277a408be9352
Reviewed-on: https://gerrit.libreoffice.org/47675
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-01-09 23:21:47 +01:00
Noel Grandin
21e0d8162a loplugin:unusedfields
fix the ReturnStmt check

Change-Id: I95076076bd1313d23798c4615ea12910c86ed9a8
Reviewed-on: https://gerrit.libreoffice.org/47309
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-01-04 07:17:23 +01:00
Noel Grandin
d43e694d5e some global loplugin improvements
for some reason we're hitting more template AST nodes now? Anyhow,
updated singlevalfields and unusedenumconstants to cope.

For unusedfields, ignore field access inside Clone() methods, since it's
like a constructor.
Similarly for unusedmethods.

Change-Id: Icb2f76fb2f06ae5df21f9d75312e42a2800befb9
Reviewed-on: https://gerrit.libreoffice.org/45470
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-30 07:20:23 +01:00
Noel Grandin
4887f9fe2d loplugin:unusedfields
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-09 13:57:13 +01:00
Stephan Bergmann
b35bb38f18 Clean away temporarily added using declarations
Change-Id: I26734c13515394162d88351a1cbe2b20abdac865
2017-11-07 11:50:47 +01:00
Noel Grandin
5585bc2fbb rename loplugin::Plugin::parentStmt
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
2017-10-27 10:31:42 +02:00
Stephan Bergmann
4ab071b5b5 More clang::*Type vs. llvm::*Type ambiguities
Change-Id: I52373c32818234e376d855684635f9bf1012ed5e
2017-09-29 10:44:22 +02:00
Noel Grandin
26c82bd286 loplugin:unusedfields improve finding callee
which makes absolutely no difference to the results, but anyhow, would
be a shame to waste the work

Change-Id: I4576528f30986a5ce522c76fdf21873f0ce23f0a
2017-09-29 09:10:36 +02:00
Noel Grandin
e8b5ec6590 loplugin:unusedfields, fix var taking ref
Change-Id: I0ea1f0c7488c140fca9f64de326c6ac588ece925
2017-09-21 10:01:43 +02:00
Noel Grandin
1ff0f0ba29 improve unusedfields loplugin
(*) 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-18 09:45:15 +02:00
Noel Grandin
370c71f5b1 simplify unusedfields plugin
using some wrappers around callee and caller AST nodes

Change-Id: I599a04a18caa3ada70bcb266e228208b7a81f1a1
2017-07-27 12:39:38 +02:00
Noel Grandin
8045cef05c improve unusedfields loplugin readonly analysis
(*) better analysis of init-list-expressions
(*) fix analysis of calls to members, turns out there is no parameter
offset after all
(*) check for passing arrays to functions, need to check
  if the parameter is T* or T const *
(*) check for assigning field to a T& variable

Change-Id: Ie6f07f970310c3854e74619fe4fd02a299bf6879
2017-07-24 08:39:55 +02:00
Julien Nabet
1cf7a4c39e Typo: "disposeAndClear", not "clearAndDispose"
Change-Id: I9f7f30fce9324f7ccb79e9a8ef0c13e091d7c3a3
Reviewed-on: https://gerrit.libreoffice.org/40304
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-22 14:16:03 +02:00
Noel Grandin
32878b6857 enhance unusedfields plugin to find readonly fields
Change-Id: I4da97443fc7eb14fd94959a026ab45a9256c055f
Reviewed-on: https://gerrit.libreoffice.org/40158
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-19 09:25:52 +02:00
Noel Grandin
3ef7e85deb remove some dead code from unusedfields plugin
Change-Id: I268b32270a17c0c3fcf8236c3e0eebac9a57cb5d
2017-07-14 11:53:03 +02:00
Noel Grandin
b533b2748e unusedfields plugin needs to ignore fields that have reinterpret_cast on them
Change-Id: Ie8570de6a4eafc95352899fbfd1447d7c3a84e1a
2017-07-11 16:10:01 +02:00
Noel Grandin
4f7b2ca221 loplugin:unusedfields in sc
found a couple more by running
    make build-nocheck
to exclude testing code

Also, teach unusedfields loplugin about operator<<, since
referring to a field in an ostream operator<< does not indicate a
real use, it's normally for debugging

Change-Id: I3dce22bf5afda2fd09e01de9bf1d0ef85e535aa8
Reviewed-on: https://gerrit.libreoffice.org/39625
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-06 13:00:56 +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
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
Tor Lillqvist
77da7b934d Fix compilation with Clang 3.9.1
Change-Id: I6e96064a001fd511864665fe0ef8b60d45462c12
2017-06-21 17:00:47 +03: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
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
2c83c40b43 improve unusedfields loplugin
to ignore assignments when doing writeonly analysis

Change-Id: I9eb6f2594003a610582dbc20acb7ccf14ef72c6c
2017-06-15 11:36:05 +02:00
Andrea Gelmini
5482ee62a5 Fix typos
Change-Id: Ic7fbd750321e4cfde1cfb0e04ffb545bb1f66d9c
Reviewed-on: https://gerrit.libreoffice.org/37921
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2017-06-01 09:42:53 +02:00
Noel Grandin
fd00bd0f69 loplugin:unusedfields
make it a little smarter in dealing with fields that are smart pointers

Change-Id: I44072105170882dc29fb19558f1065cffc7e5f11
Reviewed-on: https://gerrit.libreoffice.org/37751
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-05-19 09:17:06 +02:00