From 4f2ad15db535873dda9bfe248a2771023b64a43c Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Mon, 10 Aug 2020 14:52:37 -0700 Subject: [Clang] implement -fno-eliminate-unused-debug-types Fixes pr/11710. Signed-off-by: Nick Desaulniers Resubmit after breaking Windows and OSX builds. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D80242 --- clang/lib/CodeGen/CodeGenModule.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f3712ea1f541..67f06ac1c07c 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5392,16 +5392,21 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { Spec->hasDefinition()) DI->completeTemplateDefinition(*Spec); } LLVM_FALLTHROUGH; - case Decl::CXXRecord: - if (CGDebugInfo *DI = getModuleDebugInfo()) + case Decl::CXXRecord: { + CXXRecordDecl *CRD = cast(D); + if (CGDebugInfo *DI = getModuleDebugInfo()) { + if (CRD->hasDefinition()) + DI->EmitAndRetainType(getContext().getRecordType(cast(D))); if (auto *ES = D->getASTContext().getExternalSource()) if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never) - DI->completeUnusedClass(cast(*D)); + DI->completeUnusedClass(*CRD); + } // Emit any static data members, they may be definitions. - for (auto *I : cast(D)->decls()) + for (auto *I : CRD->decls()) if (isa(I) || isa(I)) EmitTopLevelDecl(I); break; + } // No code generation needed. case Decl::UsingShadow: case Decl::ClassTemplate: @@ -5587,6 +5592,25 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { EmitOMPRequiresDecl(cast(D)); break; + case Decl::Typedef: + case Decl::TypeAlias: // using foo = bar; [C++11] + if (CGDebugInfo *DI = getModuleDebugInfo()) + DI->EmitAndRetainType( + getContext().getTypedefType(cast(D))); + break; + + case Decl::Record: + if (CGDebugInfo *DI = getModuleDebugInfo()) + if (cast(D)->getDefinition()) + DI->EmitAndRetainType(getContext().getRecordType(cast(D))); + break; + + case Decl::Enum: + if (CGDebugInfo *DI = getModuleDebugInfo()) + if (cast(D)->getDefinition()) + DI->EmitAndRetainType(getContext().getEnumType(cast(D))); + break; + default: // Make sure we handled everything we should, every other kind is a // non-top-level decl. FIXME: Would be nice to have an isTopLevelDeclKind -- cgit v1.2.3