Skip to content

Commit b3cfef4

Browse files
authored
Merge pull request #6204 from augusto2112/fix-bind-gen-params-1013
Fix bind gen params 1013
2 parents 33bd308 + e4e792c commit b3cfef4

File tree

10 files changed

+59
-49
lines changed

10 files changed

+59
-49
lines changed

lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,25 @@ static constexpr OptionEnumValueElement g_running_mode[] = {
149149
"Run only this thread while stepping"},
150150
};
151151

152+
153+
// BEGIN SWIFT
154+
static constexpr OptionEnumValueElement g_bind_gen_type_params[] = {
155+
{
156+
lldb::eBindAuto,
157+
"auto",
158+
"Attempt to run the expression with bound generic parameters first, "
159+
"fallback to unbound generic parameters if binding the type parameters "
160+
"fails",
161+
},
162+
{lldb::eBind, "true", "Bind generic type parameters."},
163+
{lldb::eDontBind, "false", "Don't bind generic type parameters."},
164+
};
165+
166+
static constexpr OptionEnumValues BindGenTypeParamValue() {
167+
return OptionEnumValues(g_bind_gen_type_params);
168+
}
169+
// END SWIFT
170+
152171
llvm::StringRef RegisterNameHelpTextCallback();
153172
llvm::StringRef BreakpointIDHelpTextCallback();
154173
llvm::StringRef BreakpointIDRangeHelpTextCallback();
@@ -257,6 +276,9 @@ static constexpr CommandObject::ArgumentTableEntry g_argument_table[] = {
257276
{ lldb::eArgTypeConnectURL, "process-connect-url", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "A URL-style specification for a remote connection." },
258277
{ lldb::eArgTypeTargetID, "target-id", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The index ID for an lldb Target." },
259278
{ lldb::eArgTypeStopHookID, "stop-hook-id", CommandCompletions::eNoCompletion, {}, { nullptr, false }, "The ID you receive when you create a stop-hook." },
279+
// BEGIN SWIFT
280+
{ lldb::eArgTypeBindGenTypeParamValue, "bind-generic-types", CommandCompletions::eNoCompletion, g_bind_gen_type_params, { nullptr, false }, "Controls whether any generic types in the current context should be bound to their dynamic type before evaluating. Defaults to auto." },
281+
// END SWIFT
260282
// clang-format on
261283
};
262284

lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class OptionGroupValueObjectDisplay : public OptionGroup {
3333
return show_types || no_summary_depth != 0 || show_location ||
3434
flat_output || use_objc || max_depth != UINT32_MAX ||
3535
ptr_depth != 0 || !use_synth || be_raw || ignore_cap ||
36-
run_validator ||
37-
bind_generic_types != lldb::eBindAuto;
36+
run_validator;
3837
}
3938

4039
DumpValueObjectOptions GetAsDumpOptions(
@@ -52,7 +51,6 @@ class OptionGroupValueObjectDisplay : public OptionGroup {
5251
uint32_t ptr_depth;
5352
uint32_t elem_count;
5453
lldb::DynamicValueType use_dynamic;
55-
lldb::BindGenericTypes bind_generic_types;
5654
};
5755

5856
} // namespace lldb_private

lldb/include/lldb/Target/Target.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class SwiftASTContextForExpressions;
5454

5555
OptionEnumValues GetDynamicValueTypes();
5656

57-
OptionEnumValues GetBindGenericTypesOptions();
58-
5957
enum InlineStrategy {
6058
eInlineBreakpointsNever = 0,
6159
eInlineBreakpointsHeaders,

lldb/include/lldb/lldb-enumerations.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,15 @@ enum DynamicValueType {
501501
eDynamicDontRunTarget = 2
502502
};
503503

504-
enum BindGenericTypes {
505-
eBindAuto = 0,
506-
eBind = 1,
507-
eDontBind = 2
504+
// BEGIN SWIFT
505+
// Enumeration to control whether generic type parameters should be bound or
506+
// not in expression evaluation.
507+
enum BindGenericTypes {
508+
eBindAuto = 0,
509+
eBind = 1,
510+
eDontBind = 2
508511
};
512+
// END SWIFT
509513

510514
enum StopShowColumn {
511515
eStopShowColumnAnsiOrCaret = 0,
@@ -618,6 +622,9 @@ enum CommandArgumentType {
618622
eArgTypeConnectURL,
619623
eArgTypeTargetID,
620624
eArgTypeStopHookID,
625+
// BEGIN SWIFT
626+
eArgTypeBindGenTypeParamValue,
627+
// END SWIFT
621628
eArgTypeLastArg // Always keep this entry as the last entry in this
622629
// enumeration!!
623630
};

lldb/source/Commands/CommandObjectExpression.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue(
144144
break;
145145
}
146146

147+
// BEGIN SWIFT
148+
case '\x01': {
149+
int32_t result;
150+
result = OptionArgParser::ToOptionEnum(option_arg, BindGenTypeParamValue(),
151+
0, error);
152+
if (error.Success())
153+
bind_generic_types = (BindGenericTypes)result;
154+
break;
155+
}
156+
// END SWIFT
157+
147158
default:
148159
llvm_unreachable("Unimplemented option");
149160
}
@@ -172,6 +183,9 @@ void CommandObjectExpression::CommandOptions::OptionParsingStarting(
172183
auto_apply_fixits = eLazyBoolCalculate;
173184
top_level = false;
174185
allow_jit = true;
186+
// BEGIN SWIFT
187+
bind_generic_types = eBindAuto;
188+
// END SWIFT
175189
}
176190

177191
llvm::ArrayRef<OptionDefinition>
@@ -355,7 +369,7 @@ CommandObjectExpression::GetEvalOptions(const Target &target) {
355369
options.SetDebug(m_command_options.debug);
356370

357371
// BEGIN SWIFT
358-
options.SetBindGenericTypes(m_varobj_options.bind_generic_types);
372+
options.SetBindGenericTypes(m_command_options.bind_generic_types);
359373
// If the language was not specified in the expression command,
360374
// set it to the language in the target's properties if
361375
// specified, else default to the language for the frame.

lldb/source/Commands/CommandObjectExpression.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class CommandObjectExpression : public CommandObjectRaw,
4747
lldb::LanguageType language;
4848
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
4949
LazyBool auto_apply_fixits;
50+
// BEGIN SWIFT
51+
lldb::BindGenericTypes bind_generic_types;
52+
// END SWIFT
5053
};
5154

5255
CommandObjectExpression(CommandInterpreter &interpreter);

lldb/source/Commands/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,12 @@ let Command = "expression" in {
387387
Arg<"Boolean">,
388388
Desc<"Controls whether the expression can fall back to being JITted if it's "
389389
"not supported by the interpreter (defaults to true).">;
390+
// BEGIN SWIFT
391+
def bind_generic_types : Option<"bind-generic-types", "\\x01">,
392+
EnumArg<"BindGenTypeParamValue">, Desc<"Controls whether any "
393+
"generic types in the current context should be bound to their dynamic "
394+
"type before evaluating. Defaults to auto.">;
395+
// END SWIFT
390396
}
391397

392398
let Command = "frame diag" in {

lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ static const OptionDefinition g_option_table[] = {
5959
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount,
6060
"Treat the result of the expression as if its type is an array of this "
6161
"many values."},
62-
{LLDB_OPT_SET_1, false, "bind-generic-types", /* no short option */ 1,
63-
OptionParser::eRequiredArgument, nullptr, GetBindGenericTypesOptions(), 0,
64-
eArgTypeNone, "Controls whether any generic types in the current "
65-
"context should be bound to their dynamic concrete types before "
66-
"evaluating. Defaults to auto."}
6762
};
6863

6964
llvm::ArrayRef<OptionDefinition>
@@ -155,14 +150,6 @@ Status OptionGroupValueObjectDisplay::SetOptionValue(
155150
option_arg.str().c_str());
156151
break;
157152

158-
case 1:
159-
int32_t result;
160-
result = OptionArgParser::ToOptionEnum(option_arg, GetBindGenericTypesOptions(),
161-
0, error);
162-
if (error.Success())
163-
bind_generic_types = (lldb::BindGenericTypes)result;
164-
break;
165-
166153
default:
167154
llvm_unreachable("Unimplemented option");
168155
}
@@ -186,7 +173,6 @@ void OptionGroupValueObjectDisplay::OptionParsingStarting(
186173
be_raw = false;
187174
ignore_cap = false;
188175
run_validator = false;
189-
bind_generic_types = lldb::eBindAuto;
190176

191177
TargetSP target_sp =
192178
execution_context ? execution_context->GetTargetSP() : TargetSP();

lldb/source/Target/Target.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,30 +4231,6 @@ OptionEnumValues lldb_private::GetDynamicValueTypes() {
42314231
return OptionEnumValues(g_dynamic_value_types);
42324232
}
42334233

4234-
static constexpr OptionEnumValueElement g_bind_generic_types[] = {
4235-
{
4236-
eBindAuto,
4237-
"auto",
4238-
"Attempt to run the expression with bound generic parameters first, "
4239-
"fallback to unbound generic parameters if binding the type parameters "
4240-
"fails",
4241-
},
4242-
{
4243-
eBind,
4244-
"true",
4245-
"Bind the generic type parameters.",
4246-
},
4247-
{
4248-
eDontBind,
4249-
"false",
4250-
"Don't bind the generic type parameters.",
4251-
},
4252-
};
4253-
4254-
OptionEnumValues lldb_private::GetBindGenericTypesOptions() {
4255-
return OptionEnumValues(g_bind_generic_types);
4256-
}
4257-
42584234
static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
42594235
{
42604236
eInlineBreakpointsNever,

lldb/test/API/commands/help/TestHelp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def test_help_detailed_information_spacing(self):
268268
"""Test that we put a break between the usage and the options help lines,
269269
and between the options themselves."""
270270
self.expect("help memory read", substrs=[
271-
"[<address-expression>]\n\n --bind-generic-types <none>",
271+
"[<address-expression>]\n\n -A ( --show-all-children )",
272272
# Starts with the end of the show-all-children line
273273
"to show.\n\n -D"])
274274

0 commit comments

Comments
 (0)