Skip to content

Commit a96195e

Browse files
authored
Merge pull request #6195 from augusto2112/rev-86ad59f60
Revert "[lldb] Fix --bind-generic-types to only apply to expression"
2 parents 12ae09b + 701ada4 commit a96195e

File tree

8 files changed

+48
-51
lines changed

8 files changed

+48
-51
lines changed

lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ 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;
36+
run_validator ||
37+
bind_generic_types != lldb::eBindAuto;
3738
}
3839

3940
DumpValueObjectOptions GetAsDumpOptions(
@@ -51,6 +52,7 @@ class OptionGroupValueObjectDisplay : public OptionGroup {
5152
uint32_t ptr_depth;
5253
uint32_t elem_count;
5354
lldb::DynamicValueType use_dynamic;
55+
lldb::BindGenericTypes bind_generic_types;
5456
};
5557

5658
} // namespace lldb_private

lldb/include/lldb/Target/Target.h

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

5555
OptionEnumValues GetDynamicValueTypes();
5656

57+
OptionEnumValues GetBindGenericTypesOptions();
58+
5759
enum InlineStrategy {
5860
eInlineBreakpointsNever = 0,
5961
eInlineBreakpointsHeaders,

lldb/include/lldb/lldb-enumerations.h

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

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
504+
enum BindGenericTypes {
505+
eBindAuto = 0,
506+
eBind = 1,
507+
eDontBind = 2
511508
};
512-
// END SWIFT
513509

514510
enum StopShowColumn {
515511
eStopShowColumnAnsiOrCaret = 0,

lldb/source/Commands/CommandObjectExpression.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,6 @@ 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-
158147
default:
159148
llvm_unreachable("Unimplemented option");
160149
}
@@ -183,9 +172,6 @@ void CommandObjectExpression::CommandOptions::OptionParsingStarting(
183172
auto_apply_fixits = eLazyBoolCalculate;
184173
top_level = false;
185174
allow_jit = true;
186-
// BEGIN SWIFT
187-
bind_generic_types = eBindAuto;
188-
// END SWIFT
189175
}
190176

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

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

lldb/source/Commands/CommandObjectExpression.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@
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-
4022
class CommandObjectExpression : public CommandObjectRaw,
4123
public IOHandlerDelegate {
4224
public:
@@ -65,9 +47,6 @@ class CommandObjectExpression : public CommandObjectRaw,
6547
lldb::LanguageType language;
6648
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
6749
LazyBool auto_apply_fixits;
68-
// BEGIN SWIFT
69-
lldb::BindGenericTypes bind_generic_types;
70-
// END SWIFT
7150
};
7251

7352
CommandObjectExpression(CommandInterpreter &interpreter);

lldb/source/Commands/Options.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,6 @@ 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
396390
}
397391

398392
let Command = "frame diag" in {

lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ 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."}
6267
};
6368

6469
llvm::ArrayRef<OptionDefinition>
@@ -150,6 +155,14 @@ Status OptionGroupValueObjectDisplay::SetOptionValue(
150155
option_arg.str().c_str());
151156
break;
152157

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+
153166
default:
154167
llvm_unreachable("Unimplemented option");
155168
}
@@ -173,6 +186,7 @@ void OptionGroupValueObjectDisplay::OptionParsingStarting(
173186
be_raw = false;
174187
ignore_cap = false;
175188
run_validator = false;
189+
bind_generic_types = lldb::eBindAuto;
176190

177191
TargetSP target_sp =
178192
execution_context ? execution_context->GetTargetSP() : TargetSP();

lldb/source/Target/Target.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,6 +4231,30 @@ 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+
42344258
static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
42354259
{
42364260
eInlineBreakpointsNever,

0 commit comments

Comments
 (0)