Skip to content

[lldb] Remove use of SwiftASTContext in GetPointerByteSize (#6654) #6786

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
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
28 changes: 15 additions & 13 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2267,19 +2267,21 @@ bool TypeSystemSwiftTypeRef::IsVoidType(opaque_compiler_type_t type) {
// AST related queries
uint32_t TypeSystemSwiftTypeRef::GetPointerByteSize() {
auto impl = [&]() -> uint32_t {
if (auto *module = GetModule()) {
auto &triple = module->GetArchitecture().GetTriple();
if (triple.isArch64Bit())
return 8;
if (triple.isArch32Bit())
return 4;
if (triple.isArch16Bit())
return 2;
}
// An expression context has no module. Since it's for expression
// evaluation we might as well defer to the SwiftASTContext.
if (auto *swift_ast_context = GetSwiftASTContext())
return swift_ast_context->GetPointerByteSize();
llvm::Triple triple;
if (auto *module = GetModule())
triple = module->GetArchitecture().GetTriple();
else if (auto target_sp = GetTargetWP().lock())
triple = target_sp->GetArchitecture().GetTriple();
else
assert(false && "Expected module or target");

if (triple.isArch64Bit())
return 8;
if (triple.isArch32Bit())
return 4;
if (triple.isArch16Bit())
return 2;

return 0;
};
VALIDATE_AND_RETURN_STATIC(impl, GetPointerByteSize);
Expand Down