Skip to content

Bind generic types in the expression evaluator if dybamic types are requested #2014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ static void AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
static llvm::Optional<llvm::Error> AddVariableInfo(
lldb::VariableSP variable_sp, lldb::StackFrameSP &stack_frame_sp,
SwiftASTContextForExpressions &ast_context,
SwiftLanguageRuntime *language_runtime,
SwiftLanguageRuntime *runtime,
llvm::SmallDenseSet<const char *, 8> &processed_variables,
llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &local_variables,
lldb::DynamicValueType use_dynamic) {
Expand Down Expand Up @@ -615,6 +615,11 @@ static llvm::Optional<llvm::Error> AddVariableInfo(
return {};
}
var_type = valobj_sp->GetCompilerType();
if (use_dynamic > lldb::eNoDynamicValues) {
if (auto *stack_frame = stack_frame_sp.get())
var_type =
runtime->BindGenericTypeParameters(*stack_frame, var_type);
}
}

if (!var_type.IsValid())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,6 @@ TypeSystemSwiftTypeRef::GetSwiftified(swift::Demangle::Demangler &dem,
StringRef ident = GetObjCTypeName(node);
if (ident.empty())
return node;
auto *Module = GetModule();
if (!Module)
return node;

// This is an imported Objective-C type; look it up in the
// debug info.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class TestSwiftHeadermapConflict(TestBase):
def setUp(self):
TestBase.setUp(self)

@skipIf #FIXME: This regressed silently due to 2c911bceb06ed376801251bdfd992905a66f276c
@skipIf(bugnumber="rdar://60396797",
setting=('symbols.use-swift-clangimporter', 'false'))
@skipUnlessDarwin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,27 @@ def setUp(self):
TestBase.setUp(self)

def check_expression(self, expression, expected_result, use_summary=True):
value = self.frame().EvaluateExpression(expression)
opts = lldb.SBExpressionOptions()
opts.SetFetchDynamicValue(lldb.eDynamicCanRunTarget)
value = self.frame().EvaluateExpression(expression, opts)
self.assertTrue(value.IsValid(), expression + "returned a valid value")
if use_summary:
answer = value.GetSummary()
else:
answer = value.GetValue()
report_str = "%s expected: %s got: %s" % (
expression, expected_result, answer)
self.assertTrue(answer == expected_result, report_str)
report_str = value.GetError()
self.assertEquals(answer, expected_result, report_str)


@expectedFailureAll #FIXME: This regressed silently due to 2c911bceb06ed376801251bdfd992905a66f276c
@swiftTest
def test_expressions_in_class_functions(self):
"""Test expressions in class func contexts"""
self.build()
exe_name = "a.out"
exe = self.getBuildArtifact(exe_name)

# Create the target
target = self.dbg.CreateTarget(exe)
target = self.dbg.CreateTarget(self.getBuildArtifact())
self.assertTrue(target, VALID_TARGET)

breakpoints = [None]

# Set the breakpoints
breakpoints = [None]
for i in range(1, 8):
breakpoints.append(
target.BreakpointCreateBySourceRegex(
Expand All @@ -64,7 +59,6 @@ def test_expressions_in_class_functions(self):

# Launch the process, and do not stop at the entry point.
process = target.LaunchSimple(None, None, os.getcwd())

self.assertTrue(process, PROCESS_IS_VALID)

# Check each context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
lldbinline.MakeInlineTest(
__file__, globals(),
decorators=[
expectedFailureAll, #FIXME: This regressed silently due to 2c911bceb06ed376801251bdfd992905a66f276c
swiftTest,skipUnlessDarwin,
skipIf(bugnumber="rdar://60396797", # should work but crashes.
setting=('symbols.use-swift-clangimporter', 'false'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension Measurement where UnitType == UnitAngle {
}

func f() {
return //%self.expect('p self.radians', substrs=["(CGFloat) $R0 = 1.745"])
return //%self.expect('p self.radians', substrs=["CGFloat) $R0 = 1.745"])
//%self.expect('p self', substrs=["Measurement<UnitAngle>"])
}
}
Expand Down
3 changes: 1 addition & 2 deletions lldb/unittests/Symbol/TestSwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ TEST_F(TestSwiftASTContext, ResourceDir) {
llvm::sys::path::append(tc_rdir, "/Xcode.app/Contents/Developer/Toolchains/"
"XcodeDefault.xctoolchain/usr/lib/swift");

llvm::StringRef rdir;
auto GetResourceDir = [&](const char *triple_string,
llvm::StringRef sdk_path) {
llvm::Triple host("x86_64-apple-macosx10.14");
Expand All @@ -157,7 +156,7 @@ TEST_F(TestSwiftASTContext, ResourceDir) {
std::string(toolchain), std::string(cl_tools));
};

EXPECT_EQ(GetResourceDir({"x86_64-apple-macosx10.14"}, macosx_sdk),
EXPECT_EQ(GetResourceDir("x86_64-apple-macosx10.14", macosx_sdk),
tc_rdir.str());
EXPECT_EQ(GetResourceDir("x86_64-apple-darwin", macosx_sdk), tc_rdir);
EXPECT_EQ(GetResourceDir("aarch64-apple-ios11.3", ios_sdk), tc_rdir);
Expand Down