From 449d272daf5e99f039cdfdd25f020bd798fb9e1d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 7 Jul 2015 13:58:41 +0200 Subject: loplugin:unusedmethods vcl Change-Id: I98b88ca3369a2c888fd63796e39d42376d513002 --- compilerplugins/clang/unusedmethods.cxx | 15 +++++++++++---- compilerplugins/clang/unusedmethods.py | 13 +++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx index 7dc57e9b88c7..28683347fa1d 100644 --- a/compilerplugins/clang/unusedmethods.cxx +++ b/compilerplugins/clang/unusedmethods.cxx @@ -137,18 +137,25 @@ static bool isStandardStuff(const std::string& s) || startsWith(s, "(anonymous namespace)::"); } +// prevent recursive templates from blowing up the stack +static std::set traversedTemplateFunctionSet; + bool UnusedMethods::VisitCallExpr(CallExpr* expr) { if (ignoreLocation(expr)) { return true; } FunctionDecl* calleeFunctionDecl = expr->getDirectCallee(); - // if we see a call to a templated method, it effectively instantiates a new method, - // so we need to examine it's interior to see if it in turn calls anything else - if (calleeFunctionDecl->getTemplatedKind() != clang::FunctionDecl::TemplatedKind::TK_NonTemplate + 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()) { - TraverseFunctionDecl(calleeFunctionDecl); + if (traversedTemplateFunctionSet.insert(calleeFunctionDecl->getQualifiedNameAsString()).second) + TraverseFunctionDecl(calleeFunctionDecl); } CXXMethodDecl* calleeMethodDecl = dyn_cast_or_null(calleeFunctionDecl); diff --git a/compilerplugins/clang/unusedmethods.py b/compilerplugins/clang/unusedmethods.py index 22d7089b93df..69a253a28650 100755 --- a/compilerplugins/clang/unusedmethods.py +++ b/compilerplugins/clang/unusedmethods.py @@ -32,6 +32,19 @@ exclusionSet = set([ # used by Windows build "_Bool basegfx::B2ITuple::equalZero() const", "class basegfx::B2DPolyPolygon basegfx::unotools::UnoPolyPolygon::getPolyPolygonUnsafe() const", + "void OpenGLContext::requestSingleBufferedRendering()", + "_Bool TabitemValue::isBothAligned() const", + "_Bool TabitemValue::isNotAligned() const", + "void StyleSettings::SetSpinSize(long)", + "void StyleSettings::SetFloatTitleHeight(long)", + "void StyleSettings::SetTitleHeight(long)", + "void StyleSettings::SetUseFlatBorders(_Bool)", + "void StyleSettings::SetUseFlatMenus(_Bool)", + "void StyleSettings::SetCursorSize(long)", + "_Bool CommandMediaData::GetPassThroughToOS() const", + "void Application::AppEvent(const class ApplicationEvent &)", + # instantiated from a template in VCL, not sure why it is not being picked up + "class basegfx::B2DPolygon OutputDevice::PixelToLogic(const class basegfx::B2DPolygon &,const class MapMode &) const", ]) -- cgit