From: Adrian Prantl Date: Tue, 18 Jun 2013 23:01:56 +0000 (+0000) Subject: Emit forward decls for structs with declarations only when we are X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14c1a13e64808ccd2c39155793194ce499d82ca3;p=clang Emit forward decls for structs with declarations only when we are 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 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 07cbdeea10..a5e9e4e092 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -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(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 index 0000000000..01e3c10988 --- /dev/null +++ b/test/CodeGen/debug-info-record.c @@ -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; +} +