summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-03-04 09:24:48 +0200
committerNoel Grandin <noel@peralex.com>2016-03-04 11:48:04 +0200
commit9a1e6d916eff1236cc1be2056c91e56018a482bf (patch)
tree95c0dac3d7b10ef96174431f0363b401aec8cd1c /compilerplugins
parent6610ad9aee0c8299880cd1da6cd6a756860ccad9 (diff)
loplugin:unuseddefaultparam in sfx2
and fix an issue with calls to templated methods in the plugin Change-Id: I9c9537a0690ff671286c007846d5f4cfb7d2982b
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unuseddefaultparams.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/compilerplugins/clang/unuseddefaultparams.cxx b/compilerplugins/clang/unuseddefaultparams.cxx
index a194be26e726..e8b99d37e679 100644
--- a/compilerplugins/clang/unuseddefaultparams.cxx
+++ b/compilerplugins/clang/unuseddefaultparams.cxx
@@ -129,10 +129,17 @@ bool UnusedDefaultParams::VisitCallExpr(CallExpr * callExpr) {
if (ignoreLocation(callExpr)) {
return true;
}
- if (callExpr->getDirectCallee() == nullptr) {
+ const FunctionDecl* functionDecl;
+ if (isa<CXXMemberCallExpr>(callExpr)) {
+ functionDecl = dyn_cast<CXXMemberCallExpr>(callExpr)->getMethodDecl();
+ }
+ else {
+ functionDecl = callExpr->getDirectCallee();
+ }
+ if (functionDecl == nullptr) {
return true;
}
- const FunctionDecl* functionDecl = callExpr->getDirectCallee()->getCanonicalDecl();
+ functionDecl = functionDecl->getCanonicalDecl();
// method overrides don't always specify the same default params (althogh they probably should)
// so we need to work our way up to the root method
while (isa<CXXMethodDecl>(functionDecl)) {
@@ -141,6 +148,16 @@ bool UnusedDefaultParams::VisitCallExpr(CallExpr * callExpr) {
break;
functionDecl = *methodDecl->begin_overridden_methods();
}
+ // work our way back to the root definition for template methods
+ if (functionDecl->getInstantiatedFromMemberFunction())
+ functionDecl = functionDecl->getInstantiatedFromMemberFunction();
+ else if (functionDecl->getClassScopeSpecializationPattern())
+ functionDecl = functionDecl->getClassScopeSpecializationPattern();
+// workaround clang-3.5 issue
+#if CLANG_VERSION >= 30600
+ else if (functionDecl->getTemplateInstantiationPattern())
+ functionDecl = functionDecl->getTemplateInstantiationPattern();
+#endif
auto n = functionDecl->getNumParams();
if (n == 0 || !functionDecl->getParamDecl(n - 1)->hasDefaultArg()) {
return true;