]> granicus.if.org Git - clang/commitdiff
Emit forward decls for structs with declarations only when we are
authorAdrian Prantl <aprantl@apple.com>
Tue, 18 Jun 2013 23:01:56 +0000 (23:01 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 18 Jun 2013 23:01:56 +0000 (23:01 +0000)
limiting debug info.

FIXME: There is still work left to do here, the testcase should work even with -flimit-debug-info.

rdar://problem/14101097

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184252 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/debug-info-record.c [new file with mode: 0644]

index 07cbdeea1030621ec51c1a0b2afb0ef913e8ab34..a5e9e4e092e6ce0b9c508c81765f26cd7fe7e9dc 100644 (file)
@@ -1379,7 +1379,7 @@ llvm::DIType CGDebugInfo::getOrCreateInterfaceType(QualType D,
 /// CreateType - get structure or union type.
 llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, bool Declaration) {
   RecordDecl *RD = Ty->getDecl();
-  if (Declaration) {
+  if (DebugKind <= CodeGenOptions::LimitedDebugInfo && Declaration) {
     llvm::DIDescriptor FDContext =
       getContextDescriptor(cast<Decl>(RD->getDeclContext()));
     llvm::DIType RetTy = createRecordFwdDecl(RD, FDContext);
diff --git a/test/CodeGen/debug-info-record.c b/test/CodeGen/debug-info-record.c
new file mode 100644 (file)
index 0000000..01e3c10
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -fno-limit-debug-info -o - -emit-llvm -g %s | FileCheck %s
+// Check that we emit debug info for a struct even if it is typedef'd before using.
+// rdar://problem/14101097
+//
+// FIXME: This should work with -flimit-debug-info, too.
+//
+// CHECK: [ DW_TAG_member ] [foo]
+// CHECK: [ DW_TAG_member ] [bar]
+struct elusive_s {
+  int foo;
+  float bar;
+};
+typedef struct elusive_s* elusive_t;
+
+int baz(void* x) {
+  elusive_t s = x;
+  return s->foo;
+}
+