@@ -355,6 +355,10 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {
355
355
byte_size = form_value.Unsigned ();
356
356
break ;
357
357
358
+ case DW_AT_alignment:
359
+ alignment = form_value.Unsigned ();
360
+ break ;
361
+
358
362
case DW_AT_byte_stride:
359
363
byte_stride = form_value.Unsigned ();
360
364
break ;
@@ -1921,17 +1925,21 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
1921
1925
die.GetOffset (), attrs.name .GetCString ());
1922
1926
}
1923
1927
1924
- // If the byte size of the record is specified then overwrite the size
1925
- // that would be computed by Clang. This is only needed as LLDB's
1926
- // TypeSystemClang is always in C++ mode, but some compilers such as
1927
- // GCC and Clang give empty structs a size of 0 in C mode (in contrast to
1928
- // the size of 1 for empty structs that would be computed in C++ mode).
1929
- if (attrs.byte_size ) {
1928
+ // Setting authority byte size and alignment for empty structures.
1929
+ //
1930
+ // If the byte size or alignmenet of the record is specified then
1931
+ // overwrite the ones that would be computed by Clang.
1932
+ // This is only needed as LLDB's TypeSystemClang is always in C++ mode,
1933
+ // but some compilers such as GCC and Clang give empty structs a size of 0
1934
+ // in C mode (in contrast to the size of 1 for empty structs that would be
1935
+ // computed in C++ mode).
1936
+ if (attrs.byte_size || attrs.alignment ) {
1930
1937
clang::RecordDecl *record_decl =
1931
1938
TypeSystemClang::GetAsRecordDecl (clang_type);
1932
1939
if (record_decl) {
1933
1940
ClangASTImporter::LayoutInfo layout;
1934
- layout.bit_size = *attrs.byte_size * 8 ;
1941
+ layout.bit_size = attrs.byte_size .value_or (0 ) * 8 ;
1942
+ layout.alignment = attrs.alignment .value_or (0 ) * 8 ;
1935
1943
GetClangASTImporter ().SetRecordLayout (record_decl, layout);
1936
1944
}
1937
1945
}
@@ -2270,6 +2278,9 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
2270
2278
if (layout_info.bit_size == 0 )
2271
2279
layout_info.bit_size =
2272
2280
die.GetAttributeValueAsUnsigned (DW_AT_byte_size, 0 ) * 8 ;
2281
+ if (layout_info.alignment == 0 )
2282
+ layout_info.alignment =
2283
+ die.GetAttributeValueAsUnsigned (llvm::dwarf::DW_AT_alignment, 0 ) * 8 ;
2273
2284
2274
2285
clang::CXXRecordDecl *record_decl =
2275
2286
m_ast.GetAsCXXRecordDecl (clang_type.GetOpaqueQualType ());
0 commit comments