Skip to content

Commit de373d2

Browse files
Merge pull request #11918 from swiftlang/lldb/template-alias-to-6.3
🍒 [lldb][DWARFASTParserClang] Treat DW_TAG_template_alias like we do DW_TAG_typedef
2 parents 46503fa + 9957cbe commit de373d2

File tree

5 files changed

+348
-174
lines changed

5 files changed

+348
-174
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
638638

639639
switch (tag) {
640640
case DW_TAG_typedef:
641+
case DW_TAG_template_alias:
641642
case DW_TAG_base_type:
642643
case DW_TAG_pointer_type:
643644
case DW_TAG_reference_type:
@@ -777,7 +778,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
777778
TypeSP type_sp;
778779
CompilerType clang_type;
779780

780-
if (tag == DW_TAG_typedef) {
781+
if (tag == DW_TAG_typedef || tag == DW_TAG_template_alias) {
781782
// DeclContext will be populated when the clang type is materialized in
782783
// Type::ResolveCompilerType.
783784
PrepareContextToReceiveMembers(
@@ -865,6 +866,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
865866
encoding_data_type = Type::eEncodingIsRValueReferenceUID;
866867
break;
867868
case DW_TAG_typedef:
869+
case DW_TAG_template_alias:
868870
encoding_data_type = Type::eEncodingIsTypedefUID;
869871
break;
870872
case DW_TAG_const_type:
@@ -3848,12 +3850,10 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
38483850
}
38493851
}
38503852

3851-
DWARFASTParserClang *src_dwarf_ast_parser =
3852-
static_cast<DWARFASTParserClang *>(
3853-
SymbolFileDWARF::GetDWARFParser(*src_class_die.GetCU()));
3854-
DWARFASTParserClang *dst_dwarf_ast_parser =
3855-
static_cast<DWARFASTParserClang *>(
3856-
SymbolFileDWARF::GetDWARFParser(*dst_class_die.GetCU()));
3853+
auto *src_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3854+
SymbolFileDWARF::GetDWARFParser(*src_class_die.GetCU()));
3855+
auto *dst_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3856+
SymbolFileDWARF::GetDWARFParser(*dst_class_die.GetCU()));
38573857
auto link = [&](DWARFDIE src, DWARFDIE dst) {
38583858
auto &die_to_type = dst_class_die.GetDWARF()->GetDIEToType();
38593859
clang::DeclContext *dst_decl_ctx =

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
4747

4848
~DWARFASTParserClang() override;
4949

50+
// LLVM RTTI support
51+
static bool classof(const DWARFASTParser *Parser) {
52+
return Parser->GetKind() == Kind::DWARFASTParserClang;
53+
}
54+
5055
// DWARFASTParser interface.
5156
lldb::TypeSP
5257
ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
@@ -276,10 +281,6 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
276281
lldb::ModuleSP
277282
GetModuleForType(const lldb_private::plugin::dwarf::DWARFDIE &die);
278283

279-
static bool classof(const DWARFASTParser *Parser) {
280-
return Parser->GetKind() == Kind::DWARFASTParserClang;
281-
}
282-
283284
private:
284285
struct FieldInfo {
285286
/// Size in bits that this field occupies. Can but

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,17 +1573,17 @@ bool SymbolFileDWARF::HasForwardDeclForCompilerType(
15731573
auto clang_type_system = compiler_type.GetTypeSystem<TypeSystemClang>();
15741574
if (!clang_type_system)
15751575
return false;
1576-
DWARFASTParserClang *ast_parser =
1577-
static_cast<DWARFASTParserClang *>(clang_type_system->GetDWARFParser());
1576+
auto *ast_parser =
1577+
llvm::cast<DWARFASTParserClang>(clang_type_system->GetDWARFParser());
15781578
return ast_parser->GetClangASTImporter().CanImport(compiler_type);
15791579
}
15801580

15811581
bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
15821582
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
15831583
auto clang_type_system = compiler_type.GetTypeSystem<TypeSystemClang>();
15841584
if (clang_type_system) {
1585-
DWARFASTParserClang *ast_parser =
1586-
static_cast<DWARFASTParserClang *>(clang_type_system->GetDWARFParser());
1585+
auto *ast_parser =
1586+
llvm::cast<DWARFASTParserClang>(clang_type_system->GetDWARFParser());
15871587
if (ast_parser &&
15881588
ast_parser->GetClangASTImporter().CanImport(compiler_type))
15891589
return ast_parser->GetClangASTImporter().CompleteType(compiler_type);
@@ -1627,8 +1627,7 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
16271627

16281628
if (decl_die != def_die) {
16291629
GetDIEToType()[def_die.GetDIE()] = type;
1630-
DWARFASTParserClang *ast_parser =
1631-
static_cast<DWARFASTParserClang *>(dwarf_ast);
1630+
auto *ast_parser = llvm::cast<DWARFASTParserClang>(dwarf_ast);
16321631
ast_parser->MapDeclDIEToDefDIE(decl_die, def_die);
16331632
}
16341633

lldb/unittests/Symbol/TestClangASTImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ TEST_F(TestClangASTImporter, RecordLayoutFromOrigin) {
287287
clang_utils::SourceASTWithRecord source;
288288

289289
auto *dwarf_parser =
290-
static_cast<DWARFASTParserClang *>(source.ast->GetDWARFParser());
290+
llvm::cast<DWARFASTParserClang>(source.ast->GetDWARFParser());
291291
auto &importer = dwarf_parser->GetClangASTImporter();
292292

293293
// Set the layout for the origin decl in the origin ClangASTImporter.

0 commit comments

Comments
 (0)