aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2021-03-04 19:23:56 +0000
committerMed Ismail Bennani <medismail.bennani@gmail.com>2021-03-04 20:24:26 +0100
commitc16fef19f6b002ba6ec7104d9f7dc44fef99ef57 (patch)
tree7f8f48e87bec50ee1a17c862b9cd565649222dca /lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
parent1900503595cbb84a4c6e140a9ba1a2c574c0586d (diff)
downloadllvm-c16fef19f6b002ba6ec7104d9f7dc44fef99ef57.zip
llvm-c16fef19f6b002ba6ec7104d9f7dc44fef99ef57.tar.gz
llvm-c16fef19f6b002ba6ec7104d9f7dc44fef99ef57.tar.bz2
[lldb/Interpreter] Make OptionGroupPythonClassWithDict options non-required
When using `OptionGroupPythonClassWithDict` options in an `OptionGroup` with other `Options`, it can happen that the combinaison of some options of each group makes the command invalid. To solve that issue, this patch adds a bitmask argument to the `OptionGroupPythonClassWithDict` constuctor that is used to mark each option as required (or not). If the `required_options` bitmask isn't passed to the constructor, the class will keep its default behaviour, making the `--script-class` and `--python-function` required. rdar://65508855 Differential Revision: https://reviews.llvm.org/D97910 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp')
-rw-r--r--lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
index 654cc8f..a01c190 100644
--- a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
+++ b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
@@ -13,12 +13,10 @@
using namespace lldb;
using namespace lldb_private;
-OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
- (const char *class_use,
- bool is_class,
- int class_option,
- int key_option,
- int value_option) : m_is_class(is_class) {
+OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict(
+ const char *class_use, bool is_class, int class_option, int key_option,
+ int value_option, uint16_t required_options)
+ : m_is_class(is_class), m_required_options(required_options) {
m_key_usage_text.assign("The key for a key/value pair passed to the "
"implementation of a ");
m_key_usage_text.append(class_use);
@@ -36,7 +34,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_class_usage_text.append(".");
m_option_definition[0].usage_mask = LLDB_OPT_SET_1;
- m_option_definition[0].required = true;
+ m_option_definition[0].required = m_required_options.Test(eScriptClass);
m_option_definition[0].long_option = "script-class";
m_option_definition[0].short_option = class_option;
m_option_definition[0].validator = nullptr;
@@ -47,7 +45,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[0].usage_text = m_class_usage_text.data();
m_option_definition[1].usage_mask = LLDB_OPT_SET_2;
- m_option_definition[1].required = false;
+ m_option_definition[1].required = m_required_options.Test(eDictKey);
m_option_definition[1].long_option = "structured-data-key";
m_option_definition[1].short_option = key_option;
m_option_definition[1].validator = nullptr;
@@ -58,7 +56,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[1].usage_text = m_key_usage_text.data();
m_option_definition[2].usage_mask = LLDB_OPT_SET_2;
- m_option_definition[2].required = false;
+ m_option_definition[2].required = m_required_options.Test(eDictValue);
m_option_definition[2].long_option = "structured-data-value";
m_option_definition[2].short_option = value_option;
m_option_definition[2].validator = nullptr;
@@ -69,7 +67,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[2].usage_text = m_value_usage_text.data();
m_option_definition[3].usage_mask = LLDB_OPT_SET_3;
- m_option_definition[3].required = true;
+ m_option_definition[3].required = m_required_options.Test(ePythonFunction);
m_option_definition[3].long_option = "python-function";
m_option_definition[3].short_option = class_option;
m_option_definition[3].validator = nullptr;
@@ -78,7 +76,6 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[3].completion_type = 0;
m_option_definition[3].argument_type = eArgTypePythonFunction;
m_option_definition[3].usage_text = m_class_usage_text.data();
-
}
Status OptionGroupPythonClassWithDict::SetOptionValue(