-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb] Fix incorrect logical operator in 'if' condition check (NFC) #94779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-lldb Author: Shivam Gupta (xgupta) ChangesSource code analyser cppcheck says: Fix #89195 Full diff: https://github.com/llvm/llvm-project/pull/94779.diff 1 Files Affected:
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)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as #94775 (comment)
gentle ping! |
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
Outdated
Show resolved
Hide resolved
ping for review comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me. Please make sure you update the commit message so it accurately reflects the change since there were a few revisions. :)
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/2857 Here is the relevant piece of the build log for the reference:
|
… (NFC)" (#100561) Reverts #94779 Due to bot failures: https://lab.llvm.org/buildbot/#/builders/18/builds/1371
The code looks ok but as landed it turned @medismailben can you figure out the intent here, I'm assuming this was your code originally. |
… (NFC) (#94779) Summary: The condition checking for missing class name, interpreter dictionary, and script object incorrectly used logical AND (&&), which could never be true to enter the 'if' block. This commit uses separate if conditions for each class name, interpreter dictionary, and script object. Cought by cppcheck - lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:89:11: warning: Identical inner 'if' condition is always true. [identicalInnerCondition] lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:91:16: warning: Identical inner 'if' condition is always true. [identicalInnerCondition] Fix #89195 --------- Co-authored-by: Shivam Gupta <[email protected]> Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250553
… (NFC)" (#100561) Summary: Reverts #94779 Due to bot failures: https://lab.llvm.org/buildbot/#/builders/18/builds/1371 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250548
The condition checking for missing class name, interpreter dictionary, and script object incorrectly used logical AND (&&), which could never be true to enter the 'if' block.
This commit uses separate if conditions for each class name, interpreter dictionary, and script object.
Cought by cppcheck -
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:89:11: warning: Identical inner 'if' condition is always true. [identicalInnerCondition]
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:91:16: warning: Identical inner 'if' condition is always true. [identicalInnerCondition]
Fix #89195