Skip to content

Commit 04ac83c

Browse files
committed
Adapt DWARFDIE to upstream changes
1 parent 850c115 commit 04ac83c

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,29 @@ Type *DWARFDIE::ResolveTypeUID(const DWARFDIE &die) const {
390390

391391
static CompilerContext GetContextEntry(DWARFDIE die,
392392
bool derive_template_names) {
393-
auto ctx = [die](CompilerContextKind kind) {
394-
return CompilerContext(kind, ConstString(die.GetName()));
393+
auto get_name = [](DWARFDIE die) {
394+
const char *name = die.GetName();
395+
#ifdef LLDB_ENABLE_SWIFT
396+
// FIXME: This layering violation works around a limitation in
397+
// LLVM that prevents swiftc from emitting both DW_AT_name and
398+
// DW_AT_linkage_name on forward declarations and typedefs.
399+
//
400+
// We should not upstream this but instead fix the Swift compiler.
401+
std::string base_name;
402+
if (name && name[0] == '$') {
403+
// We should also check the unit's DW_LANG here.
404+
const char *mangled = ConstString(name).AsCString();
405+
base_name = TypeSystemSwiftTypeRef::GetBaseName(
406+
(lldb::opaque_compiler_type_t)mangled);
407+
if (!base_name.empty())
408+
return ConstString(base_name).AsCString();
409+
}
410+
#endif
411+
return name;
412+
};
413+
414+
auto ctx = [&](CompilerContextKind kind) {
415+
return CompilerContext(kind, ConstString(get_name(die)));
395416
};
396417

397418
switch (die.Tag()) {
@@ -415,7 +436,7 @@ static CompilerContext GetContextEntry(DWARFDIE die,
415436
CompilerContextKind kind = die.Tag() == DW_TAG_union_type
416437
? CompilerContextKind::Union
417438
: CompilerContextKind::ClassOrStruct;
418-
llvm::StringRef name = die.GetName();
439+
llvm::StringRef name = get_name(die);
419440
if (!derive_template_names || name.contains('<'))
420441
return CompilerContext(kind, ConstString(name));
421442

@@ -442,25 +463,6 @@ static void GetDeclContextImpl(DWARFDIE die, bool derive_template_names,
442463
}
443464

444465
// Add this DIE's contribution at the end of the chain.
445-
auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
446-
#ifdef LLDB_ENABLE_SWIFT
447-
// FIXME: This layering violation works around a limitation in
448-
// LLVM that prevents swiftc from emitting both DW_AT_name and
449-
// DW_AT_linkage_name on forward declarations and typedefs.
450-
//
451-
// We should not upstream this but instead fix the Swift compiler.
452-
std::string base_name;
453-
if (!name.empty() && name[0] == '$') {
454-
// We should also check the unit's DW_LANG here.
455-
const char *mangled = ConstString(name).AsCString();
456-
base_name = TypeSystemSwiftTypeRef::GetBaseName(
457-
(lldb::opaque_compiler_type_t)mangled);
458-
if (!base_name.empty())
459-
name = base_name;
460-
}
461-
#endif
462-
context.push_back({kind, ConstString(name)});
463-
};
464466
switch (die.Tag()) {
465467
case DW_TAG_module:
466468
case DW_TAG_namespace:

0 commit comments

Comments
 (0)