r370107 - Debug Info: Support for DW_AT_export_symbols for anonymous structs

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 27 13:17:36 PDT 2019


Author: shafik
Date: Tue Aug 27 13:17:35 2019
New Revision: 370107

URL: http://llvm.org/viewvc/llvm-project?rev=370107&view=rev
Log:
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.

Differential Revision: https://reviews.llvm.org/D66667

Added:
    cfe/trunk/test/CodeGenCXX/debug-info-export_symbols.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=370107&r1=370106&r2=370107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 27 13:17:35 2019
@@ -3121,7 +3121,8 @@ llvm::DICompositeType *CGDebugInfo::Crea
 
   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 @@ llvm::DICompositeType *CGDebugInfo::Crea
     // 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(

Added: cfe/trunk/test/CodeGenCXX/debug-info-export_symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-export_symbols.cpp?rev=370107&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-export_symbols.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-export_symbols.cpp Tue Aug 27 13:17:35 2019
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK: [[SCOPE:![0-9]+]] = distinct !DICompositeType({{.*}}flags: DIFlagTypePassByValue
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, scope: [[SCOPE]]
+// CHECK-SAME:                              DIFlagExportSymbols | DIFlagTypePassByValue
+struct A {
+ // Anonymous class exports its symbols into A
+ struct {
+     int y;
+ };
+} a;




More information about the cfe-commits mailing list