From af08085c8632504106b8a9604fee12702399b549 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 21 Nov 2014 00:20:58 +0000 Subject: DebugInfo: Fix another case of r222377 when we do have a definition of the variable, but we might not be emitting it (such as templates) llvm-svn: 222485 --- clang/lib/CodeGen/CGDebugInfo.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp') diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 9506cef31d2..e91b6fdf298 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3275,23 +3275,19 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, if (isa(VD->getDeclContext())) return; VD = cast(VD->getCanonicalDecl()); - llvm::DIDescriptor DContext = - getContextDescriptor(dyn_cast(VD->getDeclContext())); auto *VarD = cast(VD); - - // If this is only a declaration, it might be the declaration of a static - // variable with an initializer - we still want to ensure that's emitted, but - // merely calling getContextDescriptor above has already ensured that. Since - // there's no definition to emit, there's no further work to do. - if (!VarD->hasDefinition()) { + if (VarD->isStaticDataMember()) { + auto *RD = cast(VarD->getDeclContext()); + getContextDescriptor(RD); // Ensure that the type is retained even though it's otherwise unreferenced. RetainedTypes.push_back( - CGM.getContext() - .getRecordType(cast(VD->getDeclContext())) - .getAsOpaquePtr()); + CGM.getContext().getRecordType(RD).getAsOpaquePtr()); return; } + llvm::DIDescriptor DContext = + getContextDescriptor(dyn_cast(VD->getDeclContext())); + auto pair = DeclCache.insert(std::make_pair(VD, llvm::WeakVH())); if (!pair.second) return; -- cgit v1.2.3