Summary
After this patch, any AbiTagAttr attribute on a constructor/destructor
(like the ones for numerous types in libcxx) will be attached to the
declaration DW_TAG_subprogram as a DW_TAG_LLVM_annotation. E.g.,
DW_TAG_subprogram DW_AT_name ("shared_ptr") DW_AT_decl_file ("./bin/../include/c++/v1/__memory/shared_ptr.h") DW_AT_decl_line (475) DW_AT_declaration (true) DW_AT_external (true) DW_AT_accessibility (DW_ACCESS_public) DW_TAG_LLVM_annotation DW_AT_name ("abi_tag") DW_AT_const_value ("v170000")
We only emit these annotations for constructors/destructors declarations
because those don't carry linkage names, which is where this information
is usually encoded.
Motivation
TLDR: this makes it possible for LLDB to evaluate expressions involving
ABI-tagged constructors/destructors.
ABI tags affect a function's linkage name, which LLDB uses to resolve
function calls during expression evaluation. However,
constructors/destructors are emitted as declarations and can have
multiple definitions with different linkage names for a single
declaration DIE. LLDB relies on Clang to mangle the function AST node
into the correct linkage name. However, LLDB doesn't know about the
AbiTagAttr that was attached to a constructor/destructor in the
source, so there's no way to cleanly reconstruct the AST and resolve
the function symbol.
With this patch, LLDB can attach the ABI tag to the ctor/dtor decl
and let clang determine which linkage name to pick.