diff options
author | Noel Grandin <noel@peralex.com> | 2016-09-22 13:12:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-09-22 13:13:05 +0000 |
commit | 1c15a20df81fef594ef8fa887247aef9f2248c28 (patch) | |
tree | c2308bf3962efdc44d0391b26eaddb3b1155ae1f /compilerplugins | |
parent | 875c5905c71635c8e75d0756cc86d953523726e2 (diff) |
loplugin:unusedmethods unused returns
Change-Id: I4da3374e31d3c7407b401d66275da7f56ae83d30
Reviewed-on: https://gerrit.libreoffice.org/29178
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/unusedmethods.cxx | 4 | ||||
-rwxr-xr-x | compilerplugins/clang/unusedmethods.py | 19 |
2 files changed, 20 insertions, 3 deletions
diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx index a8a94a7c4b48..c16b446e5648 100644 --- a/compilerplugins/clang/unusedmethods.cxx +++ b/compilerplugins/clang/unusedmethods.cxx @@ -263,7 +263,9 @@ gotfunc: { const FunctionDecl* parentFunction = parentFunctionDecl(expr); if (parentFunction && parentFunction != calleeFunctionDecl) { - calledFromOutsideSet.insert(niceName(parentFunction)); + if (!ignoreLocation(parentFunction)) { + calledFromOutsideSet.insert(niceName(parentFunction)); + } } } diff --git a/compilerplugins/clang/unusedmethods.py b/compilerplugins/clang/unusedmethods.py index 6f679449172e..fb9412b20e13 100755 --- a/compilerplugins/clang/unusedmethods.py +++ b/compilerplugins/clang/unusedmethods.py @@ -154,7 +154,7 @@ with io.open("loplugin.unusedmethods.log", "rb", buffering=1024*1024) as txt: returnType = tokens[1] nameAndParams = tokens[2] usedReturnSet.add((normalizeTypeParams(returnType), normalizeTypeParams(nameAndParams))) - elif tokens[0] == "calledFromOutsideSet:": + elif tokens[0] == "outside:": returnType = tokens[1] nameAndParams = tokens[2] calledFromOutsideSet.add((normalizeTypeParams(returnType), normalizeTypeParams(nameAndParams))) @@ -315,7 +315,22 @@ for d in definitionSet: # ignore the SfxPoolItem CreateDefault methods for now if d[1].endswith("::CreateDefault()"): continue - tmp2set.add((method, definitionToSourceLocationMap[d])) + # ignore UNO constructor functions + if (d[0] == "class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface>" and + d[1].endswith("_createInstance(const class com::sun::star::uno::Reference<class com::sun::star::lang::XMultiServiceFactory> &)")): + continue + if (d[0] == "class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface>" and + d[1].endswith("_CreateInstance(const class com::sun::star::uno::Reference<class com::sun::star::lang::XMultiServiceFactory> &)")): + continue + # debug code + if d[1] == "writerfilter::ooxml::OOXMLPropertySet::toString()": + continue + location = definitionToSourceLocationMap[d]; + # windows only + if location.startswith("include/svl/svdde.hxx"): continue + # fluent API (return ref to self) + if location.startswith("include/tools/stream.hxx"): continue + tmp2set.add((method, location)) # print output, sorted by name and line number with open("loplugin.unusedmethods.report-returns", "wt") as f: |