[Lldb-commits] [lldb] [LLDB] [NFC] Fix a cppcheck warning in lldb/source/Utility/Scalar.cpp (PR #94775)

Shivam Gupta via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 7 10:46:22 PDT 2024


https://github.com/xgupta created https://github.com/llvm/llvm-project/pull/94775

Fixes #85985

lldb/source/Utility/Scalar.cpp:756:23: warning: Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]

>From da77334ac60233e688812e39480f58bbe1a251eb Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at gmail.com>
Date: Fri, 7 Jun 2024 23:05:13 +0530
Subject: [PATCH] [LLDB] [NFC] Fix a cppcheck warning in
 lldb/source/Utility/Scalar.cpp

Fixes #85985
---
 lldb/source/Utility/Scalar.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c70c5e1079918..c680101aa9efa 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -753,9 +753,7 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) {
       return false;
 
     case Scalar::e_int:
-      if (max_bit_pos == sign_bit_pos)
-        return true;
-      else if (sign_bit_pos < (max_bit_pos - 1)) {
+      if (sign_bit_pos < (max_bit_pos - 1)) {
         llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1);
         llvm::APInt bitwize_and = m_integer & sign_bit;
         if (bitwize_and.getBoolValue()) {



More information about the lldb-commits mailing list