summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-07-22 10:20:03 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-07-22 13:02:57 +0000
commit96d44c9b077a6cc8068067a795dc63248ab90fea (patch)
tree3a6df22d2df616d8c2568264e47a5219475cfc90 /compilerplugins
parent561cebeeba2155a7ebedbea885c9d7bf43102ec6 (diff)
loplugin:unusedmethods sc
Change-Id: I7bdb1889a942d63370731764a58f4ab524dedd8a Reviewed-on: https://gerrit.libreoffice.org/17287 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unusedmethods.cxx24
-rwxr-xr-xcompilerplugins/clang/unusedmethods.py1
2 files changed, 22 insertions, 3 deletions
diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx
index 692e91e932bc..c22c1db2cbf5 100644
--- a/compilerplugins/clang/unusedmethods.cxx
+++ b/compilerplugins/clang/unusedmethods.cxx
@@ -74,13 +74,31 @@ public:
bool VisitVarDecl( const VarDecl* );
};
-static std::string niceName(const FunctionDecl* functionDecl)
+/**
+ * We need to include the template params when we are building the set
+ * of functions we have walked already, because we need to rewalk anything instantiated with different params
+ */
+enum class NiceNameIncludeTemplateParams { NO, YES };
+static std::string niceName(const FunctionDecl* functionDecl, NiceNameIncludeTemplateParams eIncludeTemplateParams = NiceNameIncludeTemplateParams::NO)
{
std::string s =
compat::getReturnType(*functionDecl).getCanonicalType().getAsString()
+ " ";
if (isa<CXXMethodDecl>(functionDecl)) {
- s += dyn_cast<CXXMethodDecl>(functionDecl)->getParent()->getQualifiedNameAsString() + "::";
+ const CXXRecordDecl* recordDecl = dyn_cast<CXXMethodDecl>(functionDecl)->getParent();
+ s += recordDecl->getQualifiedNameAsString();
+ if (eIncludeTemplateParams == NiceNameIncludeTemplateParams::YES
+ && isa<ClassTemplateSpecializationDecl>(recordDecl))
+ {
+ const ClassTemplateSpecializationDecl* templateDecl = dyn_cast<ClassTemplateSpecializationDecl>(recordDecl);
+ s += "<";
+ for(size_t i=0; i < templateDecl->getTemplateArgs().size(); i++)
+ {
+ s += " ," + templateDecl->getTemplateArgs()[i].getAsType().getAsString();
+ }
+ s += ">";
+ }
+ s += "::";
}
s += functionDecl->getNameAsString() + "(";
bool bFirst = true;
@@ -164,7 +182,7 @@ bool UnusedMethods::VisitCallExpr(CallExpr* expr)
// if the function is templated. However, if we are inside a template function,
// calling another function on the same template, the same problem occurs.
// Rather than tracking all of that, just traverse anything we have not already traversed.
- if (traversedFunctionSet.insert(niceName(calleeFunctionDecl)).second)
+ if (traversedFunctionSet.insert(niceName(calleeFunctionDecl, NiceNameIncludeTemplateParams::YES)).second)
TraverseFunctionDecl(calleeFunctionDecl);
logCallToRootMethods(calleeFunctionDecl);
diff --git a/compilerplugins/clang/unusedmethods.py b/compilerplugins/clang/unusedmethods.py
index 640b42c371c4..f8c5ae26470c 100755
--- a/compilerplugins/clang/unusedmethods.py
+++ b/compilerplugins/clang/unusedmethods.py
@@ -56,6 +56,7 @@ exclusionSet = set([
"_Bool connectivity::OColumn::isWritable() const",
"_Bool IDocumentLinksAdministration::GetData(const class rtl::OUString &,const class rtl::OUString &,class com::sun::star::uno::Any &) const",
"_Bool IDocumentLinksAdministration::SetData(const class rtl::OUString &,const class rtl::OUString &,const class com::sun::star::uno::Any &)",
+ "_Bool ScImportExport::ImportData(const class rtl::OUString &,const class com::sun::star::uno::Any &)",
# instantiated from templates, not sure why it is not being picked up
"class basegfx::B2DPolygon OutputDevice::PixelToLogic(const class basegfx::B2DPolygon &,const class MapMode &) const",
"type-parameter-0-0 * detail::cloner::clone(type-parameter-0-0 *const)",