Commit Graph

52 Commits

Author SHA1 Message Date
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
Noel Grandin
d39717a6d6 tighten up the check a little more
Change-Id: Ic19364d2daa064a20da0ed9d9641f1646d8f6ce3
2017-05-16 09:39:23 +02:00
Noel Grandin
98c4cd372b loplugin:unusedfields improve write-only analysis
by whitelisting a couple of methods we know only write to their
parameters

Change-Id: Id7aef9c03c23d10c27707b21eb9a0db4a6c2757c
Reviewed-on: https://gerrit.libreoffice.org/37647
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-05-16 08:45:17 +02:00
Noel Grandin
fdc6f654ca remove unnecessary machine-specific data out of loplugin output
Change-Id: Ib8ac5acacb1dab80943b1193201021f9890121c3
2017-04-28 14:50:13 +02:00
Noel Grandin
f059347857 loplugin:unusedfields
improve the plugin to find fields which are only assigned to in the
constructor

Change-Id: I95b5be238ebba83d950ca15093abdd1849740359
Reviewed-on: https://gerrit.libreoffice.org/35613
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-03-24 08:57:01 +00:00
Noel Grandin
29a9e97db6 loplugin field-can-be-private in include/vcl..xmlscript
Change-Id: Ia03f7cccb256d825daa4dc6f4c0598448e46e6cf
Reviewed-on: https://gerrit.libreoffice.org/31069
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-23 07:17:50 +00:00
Noel Grandin
2f7ccd102a extend unusedfields loplugin to find fields that can be private
and apply the results in xmlscript

Change-Id: Ib126f6e1576639abfd171e99d9561be9715ece2f
2016-11-17 08:40:27 +02:00
Noel Grandin
3468dab9ff clang plugins: do "dotdot" normalisation
which fixes some false positives

Change-Id: I555349180b5ca819f29695789f1545ba2177bd09
Reviewed-on: https://gerrit.libreoffice.org/29320
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-09-27 12:08:52 +00:00
Noel Grandin
98c90acdfc loplugins: more consistent naming of output files
Change-Id: Ia26f697cb16078f235c94e4cff449a60c1bbd74e
2016-07-25 13:23:10 +02:00
Noel Grandin
442dd6a153 loplugin: move parentFunctionDecl() into common code
Change-Id: Ia10a76a98a63c6ea3b516d9146281f672b213ab3
2016-06-28 14:53:17 +02:00
Stephan Bergmann
f8a18a464e Adpat to <https://llvm.org/svn/llvm-project/cfe/trunk@273647>
"Use more ArrayRefs"

Change-Id: Ied0ab11dd9366b3f499100b2627f4919cca52c9c
2016-06-24 16:46:55 +02:00
Stephan Bergmann
2712fc0869 I assume these special plugins were not intended to be enabled unconditionally
...with fa135fd0e0 "remove unused SID constants
and associated code"

Change-Id: I51b2a9e3c8ce13401818bca0c40167a4364212f1
2016-06-02 23:46:46 +02:00
Noel Grandin
fa135fd0e0 remove unused SID constants and associated code
found with a python script that looks like:

process = subprocess.Popen(
  "git ls-files *.hrc | xargs grep -hE '#define +SID_' | cut -d ' ' -f 2 | sort -u",
  shell=True, stdout=subprocess.PIPE)
for line in iter(process.stdout.readline, b''):
  line = line.strip()
  if line.startswith("//"): continue
  if line.startswith("sfx"): continue
  if len(line) < 10: continue
  i = subprocess.check_output("git grep -nP \"#define +" + line + " \"",
                              shell=True)
  if i.count("#define") < 2: continue
  print line + "
" + i

Change-Id: I40eac2569c2b5b129d9459cb723a9d6f26d09264
Reviewed-on: https://gerrit.libreoffice.org/25715
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-06-01 06:48:13 +00:00
Noel Grandin
2c8fe2e737 update unusedmethods plugin to deal with constructors
and fix the operator< implementations in some of the other
plugins too.

Change-Id: Ie5631e0cdc8d2a994ad2af2533cdb558a6cfc035
Reviewed-on: https://gerrit.libreoffice.org/25057
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-18 10:03:44 +00:00
Noel Grandin
4fbf95deba new loplugin:unuseddefaultparams
Change-Id: I2c3e7d66be9e3883ea2801ff394948cc580d1e44
2016-02-25 11:42:35 +02:00
Noel Grandin
778e9a65bf new loplugin: find write-only fields
Change-Id: I0f83939babacf92485420ee63f290a297d7cb717
Reviewed-on: https://gerrit.libreoffice.org/22498
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2016-02-19 11:23:57 +00:00
Noel Grandin
ec3f724158 loplugin:unusedfields
Change-Id: Icac4ac1a2614e72bc9ff070819533e09eeb1a864
2015-11-30 10:34:38 +02:00
Noel Grandin
f273676325 update unusedfields plugin to use new clang warn_unused attribute support
Change-Id: I7b84de29b672e40cbf3c3d340d235f334d2be8cb
2015-11-24 11:04:33 +02:00
Noel Grandin
acc4acb9ca loplugin:unusedfields in tools/
Change-Id: Ic460bf42cbcf356cdcebbd5060a0dad3d3caa4ef
2015-11-24 08:09:24 +02:00