@@ -854,36 +854,26 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
854
854
DW_TAG_value_to_name (tag), type_name_cstr);
855
855
856
856
CompilerType enumerator_clang_type;
857
- CompilerType clang_type;
858
- clang_type = CompilerType (
859
- m_ast.weak_from_this (),
860
- dwarf->GetForwardDeclDIEToCompilerType ().lookup (die.GetDIE ()));
861
- if (!clang_type) {
862
- if (attrs.type .IsValid ()) {
863
- Type *enumerator_type =
864
- dwarf->ResolveTypeUID (attrs.type .Reference (), true );
865
- if (enumerator_type)
866
- enumerator_clang_type = enumerator_type->GetFullCompilerType ();
867
- }
857
+ if (attrs.type .IsValid ()) {
858
+ Type *enumerator_type = dwarf->ResolveTypeUID (attrs.type .Reference (), true );
859
+ if (enumerator_type)
860
+ enumerator_clang_type = enumerator_type->GetFullCompilerType ();
861
+ }
868
862
869
- if (!enumerator_clang_type) {
870
- if (attrs.byte_size ) {
871
- enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize (
872
- " " , DW_ATE_signed, *attrs.byte_size * 8 );
873
- } else {
874
- enumerator_clang_type = m_ast.GetBasicType (eBasicTypeInt);
875
- }
863
+ if (!enumerator_clang_type) {
864
+ if (attrs.byte_size ) {
865
+ enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize (
866
+ " " , DW_ATE_signed, *attrs.byte_size * 8 );
867
+ } else {
868
+ enumerator_clang_type = m_ast.GetBasicType (eBasicTypeInt);
876
869
}
877
-
878
- clang_type = m_ast.CreateEnumerationType (
879
- attrs.name .GetStringRef (),
880
- GetClangDeclContextContainingDIE (die, nullptr ),
881
- GetOwningClangModule (die), attrs.decl , enumerator_clang_type,
882
- attrs.is_scoped_enum );
883
- } else {
884
- enumerator_clang_type = m_ast.GetEnumerationIntegerType (clang_type);
885
870
}
886
871
872
+ CompilerType clang_type = m_ast.CreateEnumerationType (
873
+ attrs.name .GetStringRef (), GetClangDeclContextContainingDIE (die, nullptr ),
874
+ GetOwningClangModule (die), attrs.decl , enumerator_clang_type,
875
+ attrs.is_scoped_enum );
876
+
887
877
LinkDeclContextToDIE (TypeSystemClang::GetDeclContextForType (clang_type), die);
888
878
889
879
type_sp =
@@ -1781,65 +1771,59 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
1781
1771
assert (tag_decl_kind != -1 );
1782
1772
UNUSED_IF_ASSERT_DISABLED (tag_decl_kind);
1783
1773
bool clang_type_was_created = false ;
1784
- clang_type = CompilerType (
1785
- m_ast.weak_from_this (),
1786
- dwarf->GetForwardDeclDIEToCompilerType ().lookup (die.GetDIE ()));
1787
- if (!clang_type) {
1788
- clang::DeclContext *decl_ctx =
1789
- GetClangDeclContextContainingDIE (die, nullptr );
1790
-
1791
- PrepareContextToReceiveMembers (m_ast, GetClangASTImporter (), decl_ctx, die,
1792
- attrs.name .GetCString ());
1793
-
1794
- if (attrs.accessibility == eAccessNone && decl_ctx) {
1795
- // Check the decl context that contains this class/struct/union. If
1796
- // it is a class we must give it an accessibility.
1797
- const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind ();
1798
- if (DeclKindIsCXXClass (containing_decl_kind))
1799
- attrs.accessibility = default_accessibility;
1800
- }
1801
-
1802
- ClangASTMetadata metadata;
1803
- metadata.SetUserID (die.GetID ());
1804
- metadata.SetIsDynamicCXXType (dwarf->ClassOrStructIsVirtual (die));
1805
-
1806
- TypeSystemClang::TemplateParameterInfos template_param_infos;
1807
- if (ParseTemplateParameterInfos (die, template_param_infos)) {
1808
- clang::ClassTemplateDecl *class_template_decl =
1809
- m_ast.ParseClassTemplateDecl (
1810
- decl_ctx, GetOwningClangModule (die), attrs.accessibility ,
1811
- attrs.name .GetCString (), tag_decl_kind, template_param_infos);
1812
- if (!class_template_decl) {
1813
- if (log) {
1814
- dwarf->GetObjectFile ()->GetModule ()->LogMessage (
1815
- log,
1816
- " SymbolFileDWARF({0:p}) - {1:x16}: {2} type \" {3}\" "
1817
- " clang::ClassTemplateDecl failed to return a decl." ,
1818
- static_cast <void *>(this ), die.GetOffset (),
1819
- DW_TAG_value_to_name (tag), attrs.name .GetCString ());
1820
- }
1821
- return TypeSP ();
1822
- }
1774
+ clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (die, nullptr );
1823
1775
1824
- clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1825
- m_ast.CreateClassTemplateSpecializationDecl (
1826
- decl_ctx, GetOwningClangModule (die), class_template_decl,
1827
- tag_decl_kind, template_param_infos);
1828
- clang_type = m_ast.CreateClassTemplateSpecializationType (
1829
- class_specialization_decl);
1830
- clang_type_was_created = true ;
1776
+ PrepareContextToReceiveMembers (m_ast, GetClangASTImporter (), decl_ctx, die,
1777
+ attrs.name .GetCString ());
1831
1778
1832
- m_ast.SetMetadata (class_template_decl, metadata);
1833
- m_ast.SetMetadata (class_specialization_decl, metadata);
1834
- }
1779
+ if (attrs.accessibility == eAccessNone && decl_ctx) {
1780
+ // Check the decl context that contains this class/struct/union. If
1781
+ // it is a class we must give it an accessibility.
1782
+ const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind ();
1783
+ if (DeclKindIsCXXClass (containing_decl_kind))
1784
+ attrs.accessibility = default_accessibility;
1785
+ }
1786
+
1787
+ ClangASTMetadata metadata;
1788
+ metadata.SetUserID (die.GetID ());
1789
+ metadata.SetIsDynamicCXXType (dwarf->ClassOrStructIsVirtual (die));
1835
1790
1836
- if (!clang_type_was_created) {
1837
- clang_type_was_created = true ;
1838
- clang_type = m_ast.CreateRecordType (
1839
- decl_ctx, GetOwningClangModule (die), attrs.accessibility ,
1840
- attrs.name .GetCString (), tag_decl_kind, attrs.class_language ,
1841
- &metadata, attrs.exports_symbols );
1791
+ TypeSystemClang::TemplateParameterInfos template_param_infos;
1792
+ if (ParseTemplateParameterInfos (die, template_param_infos)) {
1793
+ clang::ClassTemplateDecl *class_template_decl =
1794
+ m_ast.ParseClassTemplateDecl (
1795
+ decl_ctx, GetOwningClangModule (die), attrs.accessibility ,
1796
+ attrs.name .GetCString (), tag_decl_kind, template_param_infos);
1797
+ if (!class_template_decl) {
1798
+ if (log) {
1799
+ dwarf->GetObjectFile ()->GetModule ()->LogMessage (
1800
+ log,
1801
+ " SymbolFileDWARF({0:p}) - {1:x16}: {2} type \" {3}\" "
1802
+ " clang::ClassTemplateDecl failed to return a decl." ,
1803
+ static_cast <void *>(this ), die.GetOffset (),
1804
+ DW_TAG_value_to_name (tag), attrs.name .GetCString ());
1805
+ }
1806
+ return TypeSP ();
1842
1807
}
1808
+
1809
+ clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1810
+ m_ast.CreateClassTemplateSpecializationDecl (
1811
+ decl_ctx, GetOwningClangModule (die), class_template_decl,
1812
+ tag_decl_kind, template_param_infos);
1813
+ clang_type =
1814
+ m_ast.CreateClassTemplateSpecializationType (class_specialization_decl);
1815
+ clang_type_was_created = true ;
1816
+
1817
+ m_ast.SetMetadata (class_template_decl, metadata);
1818
+ m_ast.SetMetadata (class_specialization_decl, metadata);
1819
+ }
1820
+
1821
+ if (!clang_type_was_created) {
1822
+ clang_type_was_created = true ;
1823
+ clang_type = m_ast.CreateRecordType (
1824
+ decl_ctx, GetOwningClangModule (die), attrs.accessibility ,
1825
+ attrs.name .GetCString (), tag_decl_kind, attrs.class_language , &metadata,
1826
+ attrs.exports_symbols );
1843
1827
}
1844
1828
1845
1829
// Store a forward declaration to this class type in case any
@@ -1924,8 +1908,6 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
1924
1908
// Can't assume m_ast.GetSymbolFile() is actually a
1925
1909
// SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
1926
1910
// binaries.
1927
- dwarf->GetForwardDeclDIEToCompilerType ()[die.GetDIE ()] =
1928
- clang_type.GetOpaqueQualType ();
1929
1911
dwarf->GetForwardDeclCompilerTypeToDIE ().try_emplace (
1930
1912
ClangUtil::RemoveFastQualifiers (clang_type).GetOpaqueQualType (),
1931
1913
*die.GetDIERef ());
0 commit comments