Similar to d39b4ce3ce8a3c256e01bdec2b140777a332a633
Using "eabi" or "gnueabi" for aarch64 targets is a common mistake and
warned by Clang Driver. We want to avoid them elsewhere as well. Just
use the common "aarch64" without other triple components.
Do not emit call to llvm.dbg.declare when the variable declaration
is a DecompositionDecl as its instance class is always unnamed.
The emitted debug declare looks like:
call void @llvm.dbg.declare(metadata ..., metadata !xx, metadata ...)
!xx = !DILocalVariable(scope: !..., file: !..., line: ..., type: !...)
In cases where a structured binding declaration is made to a struct with
bitfields:
struct A {
unsigned int x : 16;
unsigned int y : 16;
} g;
auto [a, b] = g; // structured binding declaration
Clang assigns the 'unsigned int' DWARF base type to 'a' and 'b' because
this is their deduced C++ type in the structured binding declaration.
However, their actual type in memory is 'unsigned short' as they have 16
bits allocated for each.
This is a problem for debug information consumers: if the debug
information for 'a' has the 'unsigned int' base type, a debugger will
assume it has 4 bytes, whereas it actually has a length of 2, resulting
in a read (or write) past its length.
This patch mimics GCC's behaviour: in case of structured bindings to
bitfields, the binding declaration's DWARF base type is of the target's
integer type with the same bitwidth as the bitfield.
If no suitable integer type is found in the target, no debug information
is emitted anymore in order to prevent wrong debug output.
Reviewed By: tmatheson
Differential Revision: https://reviews.llvm.org/D157479