Skip to content

Commit 3a71d18

Browse files
authored
Merge pull request #6191 from augusto2112/1013-fix-gen-bind-opt
[lldb] Fix --bind-generic-types to only apply to expression
2 parents 3eddae9 + 86ad59f commit 3a71d18

File tree

8 files changed

+51
-48
lines changed

8 files changed

+51
-48
lines changed

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: 8 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,

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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@
1919

2020
namespace lldb_private {
2121

22+
// BEGIN SWIFT
23+
static constexpr OptionEnumValueElement g_bind_gen_type_params[] = {
24+
{
25+
lldb::eBindAuto,
26+
"auto",
27+
"Attempt to run the expression with bound generic parameters first, "
28+
"fallback to unbound generic parameters if binding the type parameters "
29+
"fails",
30+
},
31+
{lldb::eBind, "true", "Bind generic type parameters."},
32+
{lldb::eDontBind, "false", "Don't bind generic type parameters."},
33+
};
34+
35+
static constexpr OptionEnumValues BindGenTypeParamValue() {
36+
return OptionEnumValues(g_bind_gen_type_params);
37+
}
38+
// END SWIFT
39+
2240
class CommandObjectExpression : public CommandObjectRaw,
2341
public IOHandlerDelegate {
2442
public:
@@ -47,6 +65,9 @@ class CommandObjectExpression : public CommandObjectRaw,
4765
lldb::LanguageType language;
4866
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
4967
LazyBool auto_apply_fixits;
68+
// BEGIN SWIFT
69+
lldb::BindGenericTypes bind_generic_types;
70+
// END SWIFT
5071
};
5172

5273
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<"Value", "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,

0 commit comments

Comments
 (0)