Kaydet (Commit) a04354ec authored tarafından Noel Grandin's avatar Noel Grandin

improve the unusedmethods plugin

to find stuff called from 2 levels+ inside template methods

Change-Id: I4ba308a992e64a091e5364b8aa89e44d6772dcb0
üst 1038d628
......@@ -33,7 +33,6 @@ to auto-remove the method declarations
Note that the actual process may involve a fair amount of undoing, hand editing, and general messing around
to get it to work :-)
TODO ignore calls from a method to itself, so we can eliminate unused recursive methods
TODO deal with calls to superclass/member constructors from other constructors, so
we can find unused constructors
TODO need to handle places where the code takes the address of a method, that needs to count
......@@ -139,7 +138,7 @@ static bool isStandardStuff(const std::string& s)
}
// prevent recursive templates from blowing up the stack
static std::set<std::string> traversedTemplateFunctionSet;
static std::set<std::string> traversedFunctionSet;
bool UnusedMethods::VisitCallExpr(CallExpr* expr)
{
......@@ -150,14 +149,12 @@ bool UnusedMethods::VisitCallExpr(CallExpr* expr)
if (calleeFunctionDecl == nullptr) {
return true;
}
// if we see a call to a templated function, it effectively creates new code,
// so we need to examine it's interior to see if it, in turn, calls anything else
if (calleeFunctionDecl->getTemplatedKind() != FunctionDecl::TemplatedKind::TK_NonTemplate
|| calleeFunctionDecl->isFunctionTemplateSpecialization())
{
if (traversedTemplateFunctionSet.insert(calleeFunctionDecl->getQualifiedNameAsString()).second)
TraverseFunctionDecl(calleeFunctionDecl);
}
// if we see a call to a function, it may effectively create new code,
// 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(calleeFunctionDecl->getQualifiedNameAsString()).second)
TraverseFunctionDecl(calleeFunctionDecl);
CXXMethodDecl* calleeMethodDecl = dyn_cast_or_null<CXXMethodDecl>(calleeFunctionDecl);
if (calleeMethodDecl == nullptr) {
......
......@@ -29,7 +29,6 @@ exclusionSet = set([
"void comphelper::IEventProcessor::release()",
"void SotMutexHolder::acquire()",
"void SotMutexHolder::release()",
"class Rectangle ComboBox::GetDropDownPosSizePixel() const"
# only used by Windows build
"_Bool basegfx::B2ITuple::equalZero() const",
"class basegfx::B2DPolyPolygon basegfx::unotools::UnoPolyPolygon::getPolyPolygonUnsafe() const",
......@@ -47,7 +46,7 @@ exclusionSet = set([
"int PhysicalFontFace::GetWidth() const",
"void PhysicalFontFace::SetBitmapSize(int,int)",
"_Bool SalObject::IsEraseBackgroundEnabled()",
# instantiated from a template in VCL, not sure why it is not being picked up
# 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",
# only used by OSX build
"void StyleSettings::SetHideDisabledMenuItems(_Bool)",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment