diff options
author | Noel Grandin <noel@peralex.com> | 2015-07-07 13:58:41 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-07-08 09:51:27 +0200 |
commit | 449d272daf5e99f039cdfdd25f020bd798fb9e1d (patch) | |
tree | fad3597606f3fbae275ff990aac45ad8f00e1c86 /compilerplugins/clang/unusedmethods.cxx | |
parent | b43fde69caf456585004b3e1da5161d76eadf057 (diff) |
loplugin:unusedmethods vcl
Change-Id: I98b88ca3369a2c888fd63796e39d42376d513002
Diffstat (limited to 'compilerplugins/clang/unusedmethods.cxx')
-rw-r--r-- | compilerplugins/clang/unusedmethods.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
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<std::string> 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<CXXMethodDecl>(calleeFunctionDecl); |