Skip to content

Commit 514fa5f

Browse files
authored
Merge pull request #7053 from augusto2112/wrap-dwim-swift
[lldb][NFC] Wrap Swift-only code in DWIM-print into commented blocks
2 parents edfa23b + 0c72723 commit 514fa5f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lldb/source/Commands/CommandObjectDWIMPrint.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
9999

100100
StackFrame *frame = m_exe_ctx.GetFramePtr();
101101

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+
102112
// First, try `expr` as the name of a frame variable.
103113
if (frame) {
104114
auto valobj_sp = frame->FindVariable(ConstString(expr));
@@ -122,6 +132,7 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
122132
}
123133
}
124134

135+
// BEGIN SWIFT
125136
// For Swift frames, rewrite `po 0x12345600` to use `unsafeBitCast`.
126137
//
127138
// This works only when the address points to an instance of a class. This
@@ -142,12 +153,7 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
142153
// 3. Require addresses to be on the heap
143154
std::string modified_expr_storage;
144155
// 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;
151157
if (is_swift && is_po) {
152158
lldb::addr_t addr;
153159
bool is_integer = !expr.getAsInteger(0, addr);
@@ -162,6 +168,7 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
162168
}
163169
}
164170
}
171+
// END SWIFT
165172

166173
// Second, also lastly, try `expr` as a source expression to evaluate.
167174
{

0 commit comments

Comments
 (0)