From: David Blaikie Date: Fri, 21 Jun 2013 21:03:11 +0000 (+0000) Subject: PR16214: Debug info for types first used via pointers or qualified types & later... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f0c31d98d3db8ed76077999d10ac45ed23f7e75e;p=clang PR16214: Debug info for types first used via pointers or qualified types & later require definitions git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184594 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index b2f3120ec3..58e492ea7d 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1951,8 +1951,15 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit, llvm::DIType T = getCompletedTypeOrNull(Ty); - if (T.Verify()) + if (T.Verify()) { + // If we're looking for a definition, make sure we have definitions of any + // underlying types. + if (const TypedefType* TTy = dyn_cast(Ty)) + getOrCreateType(TTy->getDecl()->getUnderlyingType(), Unit, Declaration); + if (Ty.hasLocalQualifiers()) + getOrCreateType(QualType(Ty.getTypePtr(), 0), Unit, Declaration); return T; + } // Otherwise create the type. llvm::DIType Res = CreateTypeNode(Ty, Unit, Declaration); diff --git a/test/CodeGenCXX/debug-info-class-limited.cpp b/test/CodeGenCXX/debug-info-class-limited.cpp new file mode 100644 index 0000000000..fd542a8bb0 --- /dev/null +++ b/test/CodeGenCXX/debug-info-class-limited.cpp @@ -0,0 +1,14 @@ +// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s + +namespace PR16214_1 { +// CHECK: [[PR16214_1:![0-9]*]] = {{.*}} [ DW_TAG_namespace ] [PR16214_1] +// CHECK: = metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata [[PR16214_1]], {{.*}} ; [ DW_TAG_structure_type ] [foo] {{.*}} [def] +struct foo { + int i; +}; + +typedef foo bar; + +bar *f; +bar g; +}