summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unusedfields.cxx
AgeCommit message (Collapse)AuthorFilesLines
2020-03-10Deref of DynTypedNode* must not outlive owning DynTypedNodeListStephan Bergmann1-2/+3
Change-Id: I8ac4a2f1e442446384b88f38bdef21644409f8a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90303 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-03-09improve loplugin:unusedfieldsNoel Grandin1-0/+51
noticed something that wasn't being picked up, wrote some tests, and found an unhandled case in Plugin::getParentFunctionDecl Change-Id: I52b4ea273be6614e197392dfc4d6053bbc1704de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90141 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-02-03loplugin:unusedfieldsNoel Grandin1-1/+4
tweak plugin with the name of another clone method Change-Id: I47193d31f53f48297c9e773da375c7255ddde282 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87852 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-01-31loplugin:unusedfields improve checking for fields guarded by existence checkNoel Grandin1-1/+20
which resulted in only a couple of real finds, mostly false+ Change-Id: I26058a29c27bff50e9526bedd54fb04589c2934d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87765 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-01-27Adapt to Clang 11 move of DynTypedNodeListStephan Bergmann1-0/+7
...in <https://github.com/llvm/llvm-project/commit/ 8a81daaa8b58aeaa192a47c4ce7f94b4d59ce082> "[AST] Split parent map traversal logic into ParentMapContext.h", causing failures like > compilerplugins/clang/constmethod.cxx: In member function ‘bool {anonymous}::ConstMethod::checkIfCanBeConst(const clang::Stmt*, const clang::CXXMethodDecl*)’: > compilerplugins/clang/constmethod.cxx:191:70: error: invalid use of incomplete type ‘class clang::DynTypedNodeList’ > 191 | auto parentsRange = compiler.getASTContext().getParents(*stmt); > | ^ > In file included from compilerplugins/clang/plugin.hxx:15, > from compilerplugins/clang/constmethod.cxx:16: > include/clang/AST/ASTContext.h:97:7: note: forward declaration of ‘class clang::DynTypedNodeList’ > 97 | class DynTypedNodeList; > | ^~~~~~~~~~~~~~~~ Change-Id: Ib82d04608fa306a715af481422017c24053a01c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87533 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-08better name for a function in compilerpluginsLuboš Luňák1-1/+1
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-07do not use compiler.getSourceManager().getFilename()Luboš Luňák1-1/+1
This is a continuation of ff002524c12471668e63837a804b6006f9136a34. 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-09-06Fixing "...."Andrea Gelmini1-1/+1
Change-Id: Id005a7531d546dd43de13b49bcb3e93081c5ad8d Reviewed-on: https://gerrit.libreoffice.org/78679 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-06-14loplugin:unusedfields improvementsNoel Grandin1-18/+39
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-02-27loplugin:unusedfields fix read/write when dealing with r<<= and >>=Noel Grandin1-1/+1
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-21loplugin:unusedfields improve write-only when dealing with operatorsNoel Grandin1-23/+41
Change-Id: I3a060d94de7c3d77a54e7f7f87bef88458ab5161 Reviewed-on: https://gerrit.libreoffice.org/68132 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-12-13loplugin:unusedfields improve write-only logicNoel Grandin1-1/+9
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-11-27add EvaluateAsInt compat function for latest clangNoel Grandin1-1/+1
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-23Bump compiler plugins Clang baseline to 5.0.2Stephan Bergmann1-8/+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-10-22loplugin:unusedfields improvemementsNoel Grandin1-1/+16
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-17loplugin:singlevalfieldsNoel Grandin1-1/+1
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-09-18loplugin:unusedfields improve search for unused collection fieldsNoel Grandin1-18/+79
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-13new loplugin:constfieldsNoel Grandin1-28/+0
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-08-14filter out some of the AST in the pluginsNoel Grandin1-2/+2
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-10Avoid -Werror=deprecated-declarations with recent Clang trunkStephan Bergmann1-8/+8
...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-07-20loplugin:unusedfields - look for fields that can be const, in comphelperNoel Grandin1-0/+32
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-02loplugin:unusedfields improve checking for write-only fieldsNoel Grandin1-3/+13
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-05-19improve unusedfields loplugin to find constructor-only fieldsNoel Grandin1-0/+5
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-04-10put the loplugin output files in the workdirNoel Grandin1-1/+1
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-10darn, unusedfields loplugin was left enabledNoel Grandin1-1/+1
Change-Id: I343262e0c61e9ecde5395f13732c212197e7fd03
2018-04-10loplugin:unusedfield improvementsNoel Grandin1-2/+27
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-01-09Don't build off-by-default loplugin:unusedfields on Windows for nowStephan Bergmann1-0/+4
...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-04loplugin:unusedfieldsNoel Grandin1-3/+8
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>
2017-11-30some global loplugin improvementsNoel Grandin1-40/+16
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-09loplugin:unusedfieldsNoel Grandin1-8/+13
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-07Clean away temporarily added using declarationsStephan Bergmann1-2/+3
Change-Id: I26734c13515394162d88351a1cbe2b20abdac865
2017-10-27rename loplugin::Plugin::parentStmtNoel Grandin1-1/+1
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-09-29More clang::*Type vs. llvm::*Type ambiguitiesStephan Bergmann1-2/+2
Change-Id: I52373c32818234e376d855684635f9bf1012ed5e
2017-09-29loplugin:unusedfields improve finding calleeNoel Grandin1-22/+100
which makes absolutely no difference to the results, but anyhow, would be a shame to waste the work Change-Id: I4576528f30986a5ce522c76fdf21873f0ce23f0a
2017-09-21loplugin:unusedfields, fix var taking refNoel Grandin1-0/+13
Change-Id: I0ea1f0c7488c140fca9f64de326c6ac588ece925
2017-09-18improve unusedfields lopluginNoel Grandin1-4/+11
(*) 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-07-27simplify unusedfields pluginNoel Grandin1-37/+38
using some wrappers around callee and caller AST nodes Change-Id: I599a04a18caa3ada70bcb266e228208b7a81f1a1
2017-07-24improve unusedfields loplugin readonly analysisNoel Grandin1-50/+65
(*) 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-22Typo: "disposeAndClear", not "clearAndDispose"Julien Nabet1-2/+2
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-19enhance unusedfields plugin to find readonly fieldsNoel Grandin1-6/+395
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-14remove some dead code from unusedfields pluginNoel Grandin1-6/+0
Change-Id: I268b32270a17c0c3fcf8236c3e0eebac9a57cb5d
2017-07-11unusedfields plugin needs to ignore fields that have reinterpret_cast on themNoel Grandin1-1/+7
Change-Id: Ie8570de6a4eafc95352899fbfd1447d7c3a84e1a
2017-07-06loplugin:unusedfields in scNoel Grandin1-8/+34
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-06-30loplugin:unusedfields in toolkit..xmloffNoel Grandin1-7/+16
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-29fix some crashes in unusedfields pluginNoel Grandin1-24/+26
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-29unusedfields loplugin writeonly analysis improvementsNoel Grandin1-5/+44
(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-21Fix compilation with Clang 3.9.1Tor Lillqvist1-1/+1
Change-Id: I6e96064a001fd511864665fe0ef8b60d45462c12
2017-06-20fix for older clang in lopluginsNoel Grandin1-1/+4
since commit 03ee996717dcf9e20529a6a3295df69d0d86dcce "loplugin:unusedfields fix more false +" Change-Id: Ief935fea8c554707db38b4ede4fab2ec1adca997
2017-06-20reformat some loplugin codeNoel Grandin1-2/+2
to match our more normal conventions. Also drop the 'using std' and some other cruft Change-Id: I02ef81c5427188bc03a20b157a57a900a9d7bf0d
2017-06-20loplugin:unusedfields fix more false +Noel Grandin1-49/+31
deal with fields assigned to local variables, and some general cleanup Change-Id: I894c74a01e9e28935ecd84308c2e92b080afafc6