summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-03-03 14:52:45 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-03-04 06:13:25 +0000
commitf5e131b2bcd2c88a47e5988d5f319bffd767c4dc (patch)
treedfa4853d09b4327c4c812dfbe3b44ec1c6447060 /compilerplugins
parentfee4fe8e589e101140d9b318ac757825bf836506 (diff)
loplugin:unuseddefaultparams in vcl and xmloff
and teach the plugin about code that takes the address of a function Change-Id: Ia9d5afef44520aca236659e8176f1e27135ef4fc Reviewed-on: https://gerrit.libreoffice.org/22861 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unuseddefaultparams.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/compilerplugins/clang/unuseddefaultparams.cxx b/compilerplugins/clang/unuseddefaultparams.cxx
index 6906a93c2271..a194be26e726 100644
--- a/compilerplugins/clang/unuseddefaultparams.cxx
+++ b/compilerplugins/clang/unuseddefaultparams.cxx
@@ -68,8 +68,11 @@ public:
myfile.close();
}
+ bool shouldVisitTemplateInstantiations () const { return true; }
+
bool VisitCallExpr(CallExpr * callExpr);
bool VisitFunctionDecl( const FunctionDecl* functionDecl );
+ bool VisitDeclRefExpr( const DeclRefExpr* declRefExpr );
private:
MyFuncInfo niceName(const FunctionDecl* functionDecl);
};
@@ -208,6 +211,18 @@ bool UnusedDefaultParams::VisitFunctionDecl( const FunctionDecl* functionDecl )
return true;
}
+// this catches places that take the address of a method
+bool UnusedDefaultParams::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
+{
+ const Decl* functionDecl = declRefExpr->getDecl();
+ if (!isa<FunctionDecl>(functionDecl)) {
+ return true;
+ }
+ MyFuncInfo funcInfo = niceName(dyn_cast<FunctionDecl>(functionDecl));
+ callSet.insert(funcInfo);
+ return true;
+}
+
loplugin::Plugin::Registration< UnusedDefaultParams > X("unuseddefaultparams", false);
}