diff options
author | ykhatav <yashasvi.khatavkar@intel.com> | 2025-05-13 11:29:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-13 11:29:53 -0400 |
commit | 3cf280c16aaf93148db9080a47f24ac76c01bde4 (patch) | |
tree | c81c7566fe4c28cd13381c1f1310dd5f22530ab4 /clang | |
parent | f4b80b9109a65bd85f1f62d47cfc9f9395e1b5cc (diff) | |
download | llvm-3cf280c16aaf93148db9080a47f24ac76c01bde4.zip llvm-3cf280c16aaf93148db9080a47f24ac76c01bde4.tar.gz llvm-3cf280c16aaf93148db9080a47f24ac76c01bde4.tar.bz2 |
Emit nested unused enum types with -fno-eliminate-unused-debug-types (#137818)
Unused types are retained in the debug info when
-fno-eliminate-unused-debug-types is specified.
However, unused nested enums were not being emitted even with this
option.
This patch fixes the missing emission of unused nested enums with
-fno-eliminate-unused-debug-types
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGen/unused_nested_enump.cpp | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 428a4b8..50041f8 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -7119,7 +7119,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { } // Emit any static data members, they may be definitions. for (auto *I : CRD->decls()) - if (isa<VarDecl>(I) || isa<CXXRecordDecl>(I)) + if (isa<VarDecl>(I) || isa<CXXRecordDecl>(I) || isa<EnumDecl>(I)) EmitTopLevelDecl(I); break; } diff --git a/clang/test/CodeGen/unused_nested_enump.cpp b/clang/test/CodeGen/unused_nested_enump.cpp new file mode 100644 index 0000000..7689b5b --- /dev/null +++ b/clang/test/CodeGen/unused_nested_enump.cpp @@ -0,0 +1,23 @@ +// 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: !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, name: "Type" + +// CHECK: ![[ELEMENTS]] = !{![[ENUMERATOR:[0-9]+]]} +// CHECK: ![[ENUMERATOR]] = !DIEnumerator(name: "Unused", value: 0 + + +// NOUNUSEDTYPE-NOT: !DIEnumerator(name: "Unused" |