@@ -99,6 +99,16 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
99
99
100
100
StackFrame *frame = m_exe_ctx.GetFramePtr ();
101
101
102
+ // BEGIN SWIFT
103
+ bool is_po = m_varobj_options.use_objc ;
104
+ // Either the language was explicitly specified, or we check the frame.
105
+ lldb::LanguageType language;
106
+ if (m_expr_options.language != lldb::eLanguageTypeUnknown)
107
+ language = m_expr_options.language ;
108
+ else if (frame)
109
+ language = frame->GuessLanguage ();
110
+ // END SWIFT
111
+
102
112
// First, try `expr` as the name of a frame variable.
103
113
if (frame) {
104
114
auto valobj_sp = frame->FindVariable (ConstString (expr));
@@ -122,6 +132,7 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
122
132
}
123
133
}
124
134
135
+ // BEGIN SWIFT
125
136
// For Swift frames, rewrite `po 0x12345600` to use `unsafeBitCast`.
126
137
//
127
138
// This works only when the address points to an instance of a class. This
@@ -142,12 +153,7 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
142
153
// 3. Require addresses to be on the heap
143
154
std::string modified_expr_storage;
144
155
// Either Swift was explicitly specified, or the frame is Swift.
145
- bool is_swift = false ;
146
- if (m_expr_options.language == lldb::eLanguageTypeSwift)
147
- is_swift = true ;
148
- else if (m_expr_options.language == lldb::eLanguageTypeUnknown)
149
- is_swift = frame && frame->GuessLanguage () == lldb::eLanguageTypeSwift;
150
- bool is_po = m_varobj_options.use_objc ;
156
+ bool is_swift = language == lldb::eLanguageTypeSwift;
151
157
if (is_swift && is_po) {
152
158
lldb::addr_t addr;
153
159
bool is_integer = !expr.getAsInteger (0 , addr);
@@ -162,6 +168,7 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
162
168
}
163
169
}
164
170
}
171
+ // END SWIFT
165
172
166
173
// Second, also lastly, try `expr` as a source expression to evaluate.
167
174
{
0 commit comments