From dbb75877c2efe075e85365dbbb315fcc25656292 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 27 Apr 2015 15:30:34 +0200 Subject: loplugin:simplifybool: Need to ignore imp. casts when determining literals Change-Id: I6b25ef369a9d445322f7500630a6a4ed38ae7d8f --- compilerplugins/clang/simplifybool.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compilerplugins/clang/simplifybool.cxx b/compilerplugins/clang/simplifybool.cxx index e30d408e9faf..9f82660dd29f 100644 --- a/compilerplugins/clang/simplifybool.cxx +++ b/compilerplugins/clang/simplifybool.cxx @@ -31,6 +31,7 @@ Expr const * getSubExprOfLogicalNegation(Expr const * expr) { enum class Value { Unknown, False, True }; Value getValue(Expr const * expr) { + expr = ignoreParenImpCastAndComma(expr); if (expr->getType()->isBooleanType()) { // Instead going via Expr::isCXX11ConstantExpr would turn up excatly one // additional place in svx/source/dialog/framelinkarray.cxx @@ -41,8 +42,7 @@ Value getValue(Expr const * expr) { // // where it is unclear whether it is not actually better to consider // DIAG_DBL_CLIP_DEFAULT a tunable parameter (and thus not to simplify): - auto lit - = dyn_cast(ignoreParenImpCastAndComma(expr)); + auto lit = dyn_cast(expr); if (lit != nullptr) { return lit->getValue() ? Value::True : Value::False; } -- cgit