]> granicus.if.org Git - clang/commitdiff
PR16214: Debug info for types first used via pointers or qualified types & later...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 21 Jun 2013 21:03:11 +0000 (21:03 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 21 Jun 2013 21:03:11 +0000 (21:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184594 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-class-limited.cpp [new file with mode: 0644]

index b2f3120ec387089ddf8a45dd0c3a000c61f1b83f..58e492ea7d9efc5818bea2b101540a2be43597a3 100644 (file)
@@ -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<TypedefType>(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 (file)
index 0000000..fd542a8
--- /dev/null
@@ -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;
+}