Bug 51277: [DWARF] DW_AT_alignment incorrect when
authorYing Yi <maggieyi868@gmail.com>
Wed, 6 Apr 2022 11:18:15 +0000 (12:18 +0100)
committerYing Yi <maggieyi666@gmail.com>
Fri, 22 Apr 2022 11:15:00 +0000 (12:15 +0100)
commitb09ba42620768c0092b20cf526a30b14752a5dc9
tree15803d4403a944b4f47e5b72c09a2c47c0064aa7
parentba46ae7bd85351359bb940c36fec67817a0e376d
Bug 51277: [DWARF] DW_AT_alignment incorrect when
attribute((__aligned__)) is present but ignored`

In the original code, the 'getDeclAlignIfRequired' function is used.
The 'getDeclAlignIfRequired' function will return the max alignment
of all aligned attributes if the type has aligned attributes. The
function doesn't consider the type at all.

The 'getTypeAlignIfRequired' function uses the type's alignment value,
which also used by the 'alignof' function. I think we should use the
function of 'getTypeAlignIfRequired'.

Reviewed By: dblaikie, jmorse, wolfgangp

Differential Revision: https://reviews.llvm.org/D124006
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-struct-align.cpp [new file with mode: 0644]