llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: ykhatav (ykhatav) <details> <summary>Changes</summary> 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 --- Full diff: https://github.com/llvm/llvm-project/pull/137818.diff 2 Files Affected: - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) - (added) clang/test/CodeGen/unused_nested_enump.cpp (+23) ``````````diff diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e917f3c42da06..d63829010b3de 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -7105,7 +7105,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 0000000000000..7689b5bd7561b --- /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" `````````` </details> https://github.com/llvm/llvm-project/pull/137818 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits