summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-10-20 14:39:48 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-10-20 14:39:48 +0200
commit931c51f65b77285d912b4f3d4a5385a82fb28172 (patch)
tree7af189344a2751cf51bd1f7203a06f9748b869b8 /compilerplugins
parente80427ca11de59e87bab9fb600a72fec8ea4d47e (diff)
Make loplugin:defaultparams handle enum values and nullptrs
Change-Id: I0c57b414d9230406cf2632494ccfa576510b0e61
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/defaultparams.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/compilerplugins/clang/defaultparams.cxx b/compilerplugins/clang/defaultparams.cxx
index e6f6921f0b89..3e5d5f826349 100644
--- a/compilerplugins/clang/defaultparams.cxx
+++ b/compilerplugins/clang/defaultparams.cxx
@@ -57,16 +57,17 @@ bool DefaultParams::VisitCallExpr(CallExpr * callExpr) {
break;
}
const Expr* defaultArgExpr = parmVarDecl->getDefaultArg();
- if (!(defaultArgExpr &&
- defaultArgExpr->getType()->isIntegralType(
- compiler.getASTContext())))
- {
+ if (!defaultArgExpr) {
break;
}
APSInt x1, x2;
- if (!(arg->EvaluateAsInt(x1, compiler.getASTContext()) &&
- defaultArgExpr->EvaluateAsInt(x2, compiler.getASTContext()) &&
- x1 == x2))
+ if (!((defaultArgExpr->isNullPointerConstant(
+ compiler.getASTContext(), Expr::NPC_NeverValueDependent)
+ && arg->isNullPointerConstant(
+ compiler.getASTContext(), Expr::NPC_NeverValueDependent))
+ || (defaultArgExpr->EvaluateAsInt(x1, compiler.getASTContext())
+ && arg->EvaluateAsInt(x2, compiler.getASTContext())
+ && x1 == x2)))
{
break;
}