Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,8 @@ void CGDebugInfo::CollectRecordFields(

// Bump field number for next field.
++fieldNo;
} else if (CGM.getCodeGenOpts().EmitCodeView) {
} else if (CGM.getCodeGenOpts().hasMaybeUnusedDebugInfo() ||
CGM.getCodeGenOpts().EmitCodeView) {
// Debug info for nested types is included in the member list only for
// CodeView.
if (const auto *nestedType = dyn_cast<TypeDecl>(I)) {
Expand Down
30 changes: 30 additions & 0 deletions clang/test/CodeGen/unused_nested_enump.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// RUN: %clang_cc1 -debug-info-kind=unused-types -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck --check-prefix=NOUNUSEDTYPE %s

struct Type {
enum { Unused };
int value = 0;
};
int main() {
Type t;
return t.value;
}

// CHECK: ![[ENUM_MEMBER:[0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type
// CHECK-SAME: scope: ![[STRUCT:[0-9]+]]
// CHECK-SAME: elements: ![[ELEMENTS:[0-9]+]]

// CHECK: ![[STRUCT]] = distinct !DICompositeType(tag: DW_TAG_structure_type
// CHECK-SAME: elements: ![[STRUCT_ELEMENTS:[0-9]+]]

// CHECK: ![[STRUCT_ELEMENTS]] = !{![[ENUM_MEMBER:[0-9]+]], ![[VALUE_MEMBER:[0-9]+]]}

// CHECK: ![[VALUE_MEMBER]] = !DIDerivedType(tag: DW_TAG_member
// CHECK-SAME: name: "value"
// CHECK-SAME: scope: ![[STRUCT]]

// CHECK: ![[ELEMENTS]] = !{![[ENUMERATOR:[0-9]+]]}
// CHECK: ![[ENUMERATOR]] = !DIEnumerator(name: "Unused", value: 0


// NOUNUSEDTYPE-NOT: !DIEnumerator(name: "Unused"