loplugin:unusedmethods
Change-Id: If5090c330e12d6e537766bf4a9be0a2360381a7a Reviewed-on: https://gerrit.libreoffice.org/17312 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
committed by
Noel Grandin
parent
2c6ad5343d
commit
38023af6c1
@@ -74,30 +74,24 @@ public:
|
||||
bool VisitVarDecl( const VarDecl* );
|
||||
};
|
||||
|
||||
/**
|
||||
* 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)
|
||||
static std::string niceName(const FunctionDecl* functionDecl)
|
||||
{
|
||||
if (functionDecl->getInstantiatedFromMemberFunction())
|
||||
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
|
||||
else if (functionDecl->getClassScopeSpecializationPattern())
|
||||
functionDecl = functionDecl->getClassScopeSpecializationPattern();
|
||||
// workaround clang-3.5 issue
|
||||
#if __clang_major__ > 3 || ( __clang_major__ == 3 && __clang_minor__ >= 6 )
|
||||
else if (functionDecl->getTemplateInstantiationPattern())
|
||||
functionDecl = functionDecl->getTemplateInstantiationPattern();
|
||||
#endif
|
||||
|
||||
std::string s =
|
||||
compat::getReturnType(*functionDecl).getCanonicalType().getAsString()
|
||||
+ " ";
|
||||
if (isa<CXXMethodDecl>(functionDecl)) {
|
||||
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() + "(";
|
||||
@@ -164,7 +158,7 @@ static bool isStandardStuff(const std::string& input)
|
||||
}
|
||||
|
||||
// prevent recursive templates from blowing up the stack
|
||||
static std::set<std::string> traversedFunctionSet;
|
||||
static std::set<const FunctionDecl*> traversedFunctionSet;
|
||||
|
||||
bool UnusedMethods::VisitCallExpr(CallExpr* expr)
|
||||
{
|
||||
@@ -182,7 +176,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, NiceNameIncludeTemplateParams::YES)).second)
|
||||
if (traversedFunctionSet.insert(calleeFunctionDecl).second)
|
||||
TraverseFunctionDecl(calleeFunctionDecl);
|
||||
|
||||
logCallToRootMethods(calleeFunctionDecl);
|
||||
@@ -205,7 +199,7 @@ bool UnusedMethods::VisitCXXConstructExpr(const CXXConstructExpr* expr)
|
||||
}
|
||||
// if we see a call to a constructor, it may effectively create a whole new class,
|
||||
// if the constructor's class is templated.
|
||||
if (!traversedFunctionSet.insert(niceName(consDecl)).second)
|
||||
if (!traversedFunctionSet.insert(consDecl).second)
|
||||
return true;
|
||||
|
||||
const CXXRecordDecl* parent = consDecl->getParent();
|
||||
|
@@ -27,7 +27,7 @@ exclusionSet = set([
|
||||
"void unoidl::detail::SourceProviderScannerData::setSource(const void *,unsigned long)",
|
||||
"enum connectivity::IParseContext::InternationalKeyCode connectivity::IParseContext::getIntlKeyCode(const class rtl::OString &) const",
|
||||
"void connectivity::OSQLParser::error(const char *)",
|
||||
"void connectivity::OSQLParseNode::insert(unsigned int,class connectivity::OSQLParseNode *)"
|
||||
"void connectivity::OSQLParseNode::insert(unsigned int,class connectivity::OSQLParseNode *)",
|
||||
# TODO track instantiations of template class constructors
|
||||
"void comphelper::IEventProcessor::release()",
|
||||
"void SotMutexHolder::acquire()",
|
||||
@@ -35,6 +35,7 @@ exclusionSet = set([
|
||||
# only used by Windows build
|
||||
"_Bool basegfx::B2ITuple::equalZero() const",
|
||||
"class basegfx::B2DPolyPolygon basegfx::unotools::UnoPolyPolygon::getPolyPolygonUnsafe() const",
|
||||
"void basegfx::B2IRange::expand(const basegfx::B2ITuple &)",
|
||||
"void OpenGLContext::requestSingleBufferedRendering()",
|
||||
"_Bool TabitemValue::isBothAligned() const",
|
||||
"_Bool TabitemValue::isNotAligned() const",
|
||||
@@ -57,6 +58,8 @@ exclusionSet = set([
|
||||
"_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 &)",
|
||||
"void* ScannerManager::GetData()",
|
||||
"void ScannerManager::SetData(void *)",
|
||||
# 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)",
|
||||
|
Reference in New Issue
Block a user