r184252 - Emit forward decls for structs with declarations only when we are

Adrian Prantl aprantl at apple.com
Tue Jun 18 16:01:56 PDT 2013


Author: adrian
Date: Tue Jun 18 18:01:56 2013
New Revision: 184252

URL: http://llvm.org/viewvc/llvm-project?rev=184252&view=rev
Log:
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

Added:
    cfe/trunk/test/CodeGen/debug-info-record.c
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=184252&r1=184251&r2=184252&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jun 18 18:01:56 2013
@@ -1379,7 +1379,7 @@ llvm::DIType CGDebugInfo::getOrCreateInt
 /// 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);

Added: cfe/trunk/test/CodeGen/debug-info-record.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-record.c?rev=184252&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-record.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-record.c Tue Jun 18 18:01:56 2013
@@ -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;
+}
+





More information about the cfe-commits mailing list