[PATCH] D66667: Debug Info: Support for DW_AT_export_symbols for anonymous structs

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 23 10:55:14 PDT 2019


shafik created this revision.
shafik added a reviewer: aprantl.
shafik added a project: debug-info.
shafik added a parent revision: D66605: Debug Info: Support for DW_AT_export_symbols for anonymous structs.

This implements the DWARF 5 feature described in:

http://dwarfstd.org/ShowIssue.php?issue=141212.1

To support recognizing anonymous structs:

  struct A { 
    struct { // Anonymous struct 
        int y;
    };  
  } a;

This patch adds support in `CGDebugInfo::CreateLimitedType(...)` for this new flag and an accompanying test to verify this feature.


https://reviews.llvm.org/D66667

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-export_symbols.cpp


Index: test/CodeGenCXX/debug-info-export_symbols.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/debug-info-export_symbols.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK-DAG: !DICompositeType({{.*}}flags: DIFlagExportSymbols | DIFlagTypePassByValue
+struct A {
+ // Anonymous class exports its symbols into A
+ struct {
+     int y;
+ };
+} a;
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3121,7 +3121,8 @@
 
   SmallString<256> Identifier = getTypeIdentifier(Ty, CGM, TheCU);
 
-  // Explicitly record the calling convention for C++ records.
+  // Explicitly record the calling convention and export symbols for C++
+  // records.
   auto Flags = llvm::DINode::FlagZero;
   if (auto CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
     if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
@@ -3132,6 +3133,10 @@
     // Record if a C++ record is non-trivial type.
     if (!CXXRD->isTrivial())
       Flags |= llvm::DINode::FlagNonTrivial;
+
+    // Record exports it symbols to the containing structure.
+    if (CXXRD->isAnonymousStructOrUnion())
+        Flags |= llvm::DINode::FlagExportSymbols;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66667.216900.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190823/ce0dd778/attachment-0001.bin>


More information about the cfe-commits mailing list