[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Tue Oct 20 05:40:14 PDT 2015


 compilerplugins/clang/defaultparams.cxx |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 931c51f65b77285d912b4f3d4a5385a82fb28172
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 20 14:39:48 2015 +0200

    Make loplugin:defaultparams handle enum values and nullptrs
    
    Change-Id: I0c57b414d9230406cf2632494ccfa576510b0e61

diff --git a/compilerplugins/clang/defaultparams.cxx b/compilerplugins/clang/defaultparams.cxx
index e6f6921..3e5d5f8 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;
         }


More information about the Libreoffice-commits mailing list