Skip to content

Commit 9cd5837

Browse files
Merge pull request #2015 from adrian-prantl/binding-next
Bind generic types in the expression evaluator if dybamic types are r…
2 parents ffecabc + 9788e57 commit 9cd5837

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static void AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
581581
static llvm::Optional<llvm::Error> AddVariableInfo(
582582
lldb::VariableSP variable_sp, lldb::StackFrameSP &stack_frame_sp,
583583
SwiftASTContextForExpressions &ast_context,
584-
SwiftLanguageRuntime *language_runtime,
584+
SwiftLanguageRuntime *runtime,
585585
llvm::SmallDenseSet<const char *, 8> &processed_variables,
586586
llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &local_variables,
587587
lldb::DynamicValueType use_dynamic) {
@@ -615,6 +615,11 @@ static llvm::Optional<llvm::Error> AddVariableInfo(
615615
return {};
616616
}
617617
var_type = valobj_sp->GetCompilerType();
618+
if (use_dynamic > lldb::eNoDynamicValues) {
619+
if (auto *stack_frame = stack_frame_sp.get())
620+
var_type =
621+
runtime->BindGenericTypeParameters(*stack_frame, var_type);
622+
}
618623
}
619624

620625
if (!var_type.IsValid())

lldb/test/API/lang/swift/expression/static/TestSwiftExpressionsInClassFunctions.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,27 @@ def setUp(self):
2828
TestBase.setUp(self)
2929

3030
def check_expression(self, expression, expected_result, use_summary=True):
31-
value = self.frame().EvaluateExpression(expression)
31+
opts = lldb.SBExpressionOptions()
32+
opts.SetFetchDynamicValue(lldb.eDynamicCanRunTarget)
33+
value = self.frame().EvaluateExpression(expression, opts)
3234
self.assertTrue(value.IsValid(), expression + "returned a valid value")
3335
if use_summary:
3436
answer = value.GetSummary()
3537
else:
3638
answer = value.GetValue()
37-
report_str = "%s expected: %s got: %s" % (
38-
expression, expected_result, answer)
39-
self.assertTrue(answer == expected_result, report_str)
39+
report_str = value.GetError()
40+
self.assertEquals(answer, expected_result, report_str)
4041

4142

4243
@swiftTest
4344
def test_expressions_in_class_functions(self):
4445
"""Test expressions in class func contexts"""
4546
self.build()
46-
exe_name = "a.out"
47-
exe = self.getBuildArtifact(exe_name)
48-
49-
# Create the target
50-
target = self.dbg.CreateTarget(exe)
47+
target = self.dbg.CreateTarget(self.getBuildArtifact())
5148
self.assertTrue(target, VALID_TARGET)
5249

53-
breakpoints = [None]
54-
5550
# Set the breakpoints
51+
breakpoints = [None]
5652
for i in range(1, 8):
5753
breakpoints.append(
5854
target.BreakpointCreateBySourceRegex(
@@ -63,7 +59,6 @@ def test_expressions_in_class_functions(self):
6359

6460
# Launch the process, and do not stop at the entry point.
6561
process = target.LaunchSimple(None, None, os.getcwd())
66-
6762
self.assertTrue(process, PROCESS_IS_VALID)
6863

6964
# Check each context

lldb/unittests/Symbol/TestSwiftASTContext.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ TEST_F(TestSwiftASTContext, ResourceDir) {
147147
llvm::sys::path::append(tc_rdir, "/Xcode.app/Contents/Developer/Toolchains/"
148148
"XcodeDefault.xctoolchain/usr/lib/swift");
149149

150-
llvm::StringRef rdir;
151150
auto GetResourceDir = [&](const char *triple_string,
152151
llvm::StringRef sdk_path) {
153152
llvm::Triple host("x86_64-apple-macosx10.14");
@@ -159,7 +158,7 @@ TEST_F(TestSwiftASTContext, ResourceDir) {
159158
std::string(toolchain), std::string(cl_tools));
160159
};
161160

162-
EXPECT_EQ(GetResourceDir({"x86_64-apple-macosx10.14"}, macosx_sdk),
161+
EXPECT_EQ(GetResourceDir("x86_64-apple-macosx10.14", macosx_sdk),
163162
tc_rdir.str());
164163
EXPECT_EQ(GetResourceDir("x86_64-apple-darwin", macosx_sdk), tc_rdir);
165164
EXPECT_EQ(GetResourceDir("aarch64-apple-ios11.3", ios_sdk), tc_rdir);

0 commit comments

Comments
 (0)