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>
This commit is contained in:
Noel Grandin
2015-07-22 10:20:03 +02:00
committed by Noel Grandin
parent 561cebeeba
commit 96d44c9b07
130 changed files with 38 additions and 833 deletions

View File

@@ -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);

View File

@@ -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)",