[Lldb-commits] [lldb] [lldb] Fix incorrect logical operator in 'if' condition check (NFC) (PR #94779)

Shivam Gupta via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 19 01:17:05 PDT 2024


https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/94779

>From b8a387d82ed90c98f6bc9c0c7f9bc9da0d8e4d18 Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at gmail.com>
Date: Fri, 7 Jun 2024 23:21:15 +0530
Subject: [PATCH 1/2] [LLDB][NFC] Fix a cppcheck warning in
 Python/Interfaces/ScriptedPythonInterface.h

Fix #89195
---
 .../Python/Interfaces/ScriptedPythonInterface.h                 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 163659234466d..30811639c9a95 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -85,7 +85,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
     bool has_class_name = !class_name.empty();
     bool has_interpreter_dict =
         !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-    if (!has_class_name && !has_interpreter_dict && !script_obj) {
+    if (!has_class_name || !has_interpreter_dict || !script_obj) {
       if (!has_class_name)
         return create_error("Missing script class name.");
       else if (!has_interpreter_dict)

>From 7a53eeb7c42c79f7637a8900a02e782f385d494f Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at gmail.com>
Date: Wed, 19 Jun 2024 13:46:57 +0530
Subject: [PATCH 2/2] simplify condition

---
 .../Interfaces/ScriptedPythonInterface.h       | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 30811639c9a95..3d7c640a686ae 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -85,13 +85,17 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
     bool has_class_name = !class_name.empty();
     bool has_interpreter_dict =
         !(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
-    if (!has_class_name || !has_interpreter_dict || !script_obj) {
-      if (!has_class_name)
-        return create_error("Missing script class name.");
-      else if (!has_interpreter_dict)
-        return create_error("Invalid script interpreter dictionary.");
-      else
-        return create_error("Missing scripting object.");
+
+    if (!has_class_name) {
+      return create_error("Missing script class name.");
+    }
+
+    if (!has_interpreter_dict) {
+      return create_error("Invalid script interpreter dictionary.");
+    }
+
+    if (!script_obj) {
+      return create_error("Missing scripting object.");
     }
 
     Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,



More information about the lldb-commits mailing list