aaboud created this revision.
aaboud added reviewers: rnk, majnemer.
aaboud added subscribers: cfe-commits, bwyma.

Allow creating DI metadata for non-zero width unnamed bitfield members when 
emitting CodeView.
This is needed for patch D21489.

http://reviews.llvm.org/D21766

Files:
  lib/CodeGen/CGDebugInfo.cpp

Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1010,14 +1010,20 @@
     const RecordDecl *RD) {
   StringRef name = field->getName();
   QualType type = field->getType();
+  bool EmitCodeView = CGM.getCodeGenOpts().EmitCodeView;
 
   // Ignore unnamed fields unless they're anonymous structs/unions.
   if (name.empty() && !type->isRecordType())
-    return;
+    // Do not ignore anonymous bitfield when emitting CodeView.
+    if(!EmitCodeView || !field->isBitField())
+      return;
 
   uint64_t SizeInBitsOverride = 0;
   if (field->isBitField()) {
     SizeInBitsOverride = field->getBitWidthValue(CGM.getContext());
+    if (!SizeInBitsOverride && name.empty())
+      // Ignore unnamed 0-width bitfield.
+      return;
     assert(SizeInBitsOverride && "found named 0-width bitfield");
   }
 


Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1010,14 +1010,20 @@
     const RecordDecl *RD) {
   StringRef name = field->getName();
   QualType type = field->getType();
+  bool EmitCodeView = CGM.getCodeGenOpts().EmitCodeView;
 
   // Ignore unnamed fields unless they're anonymous structs/unions.
   if (name.empty() && !type->isRecordType())
-    return;
+    // Do not ignore anonymous bitfield when emitting CodeView.
+    if(!EmitCodeView || !field->isBitField())
+      return;
 
   uint64_t SizeInBitsOverride = 0;
   if (field->isBitField()) {
     SizeInBitsOverride = field->getBitWidthValue(CGM.getContext());
+    if (!SizeInBitsOverride && name.empty())
+      // Ignore unnamed 0-width bitfield.
+      return;
     assert(SizeInBitsOverride && "found named 0-width bitfield");
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to