From 931c51f65b77285d912b4f3d4a5385a82fb28172 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 20 Oct 2015 14:39:48 +0200 Subject: Make loplugin:defaultparams handle enum values and nullptrs Change-Id: I0c57b414d9230406cf2632494ccfa576510b0e61 --- compilerplugins/clang/defaultparams.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'compilerplugins') 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; } -- cgit