diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-27 12:52:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-28 07:17:51 +0200 |
commit | b32ead5dd27c6f2b760e4196ebe0378fb8ec1a69 (patch) | |
tree | e647c37f069db3be229a4b89bc44fd21e64128fa /compilerplugins | |
parent | 3956e4cb58033cae360beddf97136596ff3bb740 (diff) |
loplugin:checkunusedparams more part1
seems I got one of the checks wrong, and was missing a bunch of stuff
Change-Id: I2c662fc4e735f8d6cbe56c6f82906a60a580331b
Reviewed-on: https://gerrit.libreoffice.org/40481
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/checkunusedparams.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/compilerplugins/clang/checkunusedparams.cxx b/compilerplugins/clang/checkunusedparams.cxx index 790236873d99..4dc7ac0bba7d 100644 --- a/compilerplugins/clang/checkunusedparams.cxx +++ b/compilerplugins/clang/checkunusedparams.cxx @@ -10,6 +10,7 @@ #include <cassert> #include <string> #include <set> +#include <iostream> #include "plugin.hxx" @@ -80,7 +81,11 @@ bool CheckUnusedParams::VisitDeclRefExpr(DeclRefExpr const * declRef) { static int noFieldsInRecord(RecordType const * recordType) { - return std::distance(recordType->getDecl()->field_begin(), recordType->getDecl()->field_end()); + auto recordDecl = recordType->getDecl(); + // if it's complicated, lets just assume it has fields + if (isa<ClassTemplateSpecializationDecl>(recordDecl)) + return 1; + return std::distance(recordDecl->field_begin(), recordDecl->field_end()); } static bool startswith(const std::string& rStr, const char* pSubStr) { return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; @@ -291,6 +296,27 @@ bool CheckUnusedParams::VisitFunctionDecl(FunctionDecl const * decl) { // bool marker parameter if (fqn == "SvxIconReplacementDialog::SvxIconReplacementDialog") return true; + // callback + if (fqn == "basctl::SIDEModel_createInstance") + return true; + // callback + if (startswith(fqn, "SbRtl_")) + return true; + // takes pointer to fn + if (fqn == "migration::BasicMigration_create" || fqn == "migration::WordbookMigration_create" + || fqn == "FontIdentificator_createInstance" || fqn == "vcl::DragSource_createInstance" + || fqn == "vcl::DropTarget_createInstance" || fqn == "vcl::FontIdentificator_createInstance" + || fqn == "drawinglayer::unorenderer::XPrimitive2DRenderer_createInstance") + return true; + // TODO + if (fqn == "FontSubsetInfo::CreateFontSubsetFromType1") + return true; + // used in template magic + if (fqn == "MtfRenderer::MtfRenderer") + return true; + // FIXME + if (fqn == "GtkSalDisplay::filterGdkEvent") + return true; // ignore the LINK macros from include/tools/link.hxx if (decl->getLocation().isMacroID()) @@ -298,6 +324,8 @@ bool CheckUnusedParams::VisitFunctionDecl(FunctionDecl const * decl) { for( auto it = decl->param_begin(); it != decl->param_end(); ++it) { auto param = *it; + if (fqn.find("fillShapeProperties") != std::string::npos) + param->dump(); if (param->hasAttr<UnusedAttr>()) continue; if (!param->getName().empty()) |