Skip to content

[lldb] Make use of target triple in TypeSystemSwiftTypeRef #6692

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
25 changes: 9 additions & 16 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,6 @@ TypeSystemSwiftTypeRef::GetSwiftName(const clang::Decl *clang_decl,
// swiftification rules.
if (auto *importer = GetNameImporter())
return importer->ImportName(named_decl);
if (auto *swift_ast_context = GetSwiftASTContext())
return swift_ast_context->ImportName(named_decl);
return {};
}

Expand Down Expand Up @@ -1495,10 +1493,7 @@ swift::DWARFImporterDelegate &TypeSystemSwiftTypeRef::GetDWARFImporterDelegate()
return *m_dwarf_importer_delegate_up;
}

ClangNameImporter *
TypeSystemSwiftTypeRef::GetNameImporter() const {
if (llvm::isa<TypeSystemSwiftTypeRefForExpressions>(this) || !m_module)
return nullptr;
ClangNameImporter *TypeSystemSwiftTypeRef::GetNameImporter() const {
if (!m_name_importer_up) {
swift::LangOptions lang_opts;
lang_opts.setTarget(GetTriple());
Expand All @@ -1509,8 +1504,13 @@ TypeSystemSwiftTypeRef::GetNameImporter() const {
}

llvm::Triple TypeSystemSwiftTypeRef::GetTriple() const {
if (m_module)
return m_module->GetArchitecture().GetTriple();
if (auto *module = GetModule())
return module->GetArchitecture().GetTriple();
else if (auto target_sp = GetTargetWP().lock())
return target_sp->GetArchitecture().GetTriple();
LLDB_LOGF(
GetLog(LLDBLog::Types),
"Cannot determine triple when no Module or no Target is available.");
return {};
}

Expand Down Expand Up @@ -2282,14 +2282,7 @@ bool TypeSystemSwiftTypeRef::IsVoidType(opaque_compiler_type_t type) {
// AST related queries
uint32_t TypeSystemSwiftTypeRef::GetPointerByteSize() {
auto impl = [&]() -> uint32_t {
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");

llvm::Triple triple = GetTriple();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lgtm.

if (triple.isArch64Bit())
return 8;
if (triple.isArch32Bit())
Expand Down