llvm-project/llvm/test/DebugInfo/Inputs/accel-imported-declaration.cpp
Michael Buch 657672667f [llvm][DebugInfo] Add DW_TAG_imported_declaration to accelerator tables
**Summary**

After this patch, `DW_TAG_imported_declaration`s will be emitted into
the DWARF accelerator tables (under `.apple_namespaces`)

**Motivation**

Currently LLDB expression evaluation doesn't see through namespace
aliases. This is because LLDB only considers namespaces that are
part of `.apple_namespaces` when building a nested namespace
identifier for C++, which currently doesn't include import
declarations. The alternative to putting imports into accelerator
tables is to do a linear scan of a `DW_TAG_namespace` and look
for import declarations that look like they would satisfy the lookup
request, which is prohibitively expensive.

**Testing**

* Added unit-test

Differential Revision: https://reviews.llvm.org/D143397
2023-02-10 01:33:51 +00:00

16 lines
276 B
C++

// Compiled on MacOS using:
// clang++ -c -std=c++2a -gdwarf-4 -O0 -o accel-imported-declaration.macho-arm64.o
namespace A {
namespace B {
namespace C {
int a = -1;
} // namespace C
} // namespace B
namespace C = B::C;
using namespace B::C;
using B::C::a;
} // namespace A