From 4ff927030141966b63e52f703d49511b2ee9ab31 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 1 Oct 2015 16:57:02 +0000 Subject: [PATCH] Module debugging: Also emit Objective-C interfaces forward declarations in their module scope when building a clang module. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249031 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 5 +++-- test/Modules/Inputs/DebugObjC.h | 2 ++ test/Modules/ModuleDebugInfo.m | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index d5ed7ea1d6..b8c66eccba 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1663,9 +1663,10 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, // debug type since we won't be able to lay out the entire type. ObjCInterfaceDecl *Def = ID->getDefinition(); if (!Def || !Def->getImplementation()) { + llvm::DIScope *Mod = getParentModuleOrNull(ID); llvm::DIType *FwdDecl = DBuilder.createReplaceableCompositeType( - llvm::dwarf::DW_TAG_structure_type, ID->getName(), TheCU, DefUnit, Line, - RuntimeLang); + llvm::dwarf::DW_TAG_structure_type, ID->getName(), Mod ? Mod : TheCU, + DefUnit, Line, RuntimeLang); ObjCInterfaceCache.push_back(ObjCInterfaceCacheEntry(Ty, FwdDecl, Unit)); return FwdDecl; } diff --git a/test/Modules/Inputs/DebugObjC.h b/test/Modules/Inputs/DebugObjC.h index 8802f4b7b0..a44a362c92 100644 --- a/test/Modules/Inputs/DebugObjC.h +++ b/test/Modules/Inputs/DebugObjC.h @@ -1,3 +1,5 @@ +@class FwdDecl; + @interface ObjCClass { int ivar; } diff --git a/test/Modules/ModuleDebugInfo.m b/test/Modules/ModuleDebugInfo.m index 8fac5f41f0..5cfeb397f9 100644 --- a/test/Modules/ModuleDebugInfo.m +++ b/test/Modules/ModuleDebugInfo.m @@ -20,6 +20,8 @@ // CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC // CHECK-SAME: isOptimized: false, // CHECK: !DICompositeType(tag: DW_TAG_structure_type, +// CHECK-SAME: name: "FwdDecl", +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, // CHECK-SAME: name: "ObjCClass", // CHECK: !DIObjCProperty(name: "property", // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "ivar" @@ -28,6 +30,9 @@ // CHECK: !DISubprogram(name: "-[ categoryMethod]" // MODULE-CHECK: !DICompositeType(tag: DW_TAG_structure_type, -// MODULE-CHECK-SAME: name: "ObjCClass", +// MODULE-CHECK-SAME: name: "FwdDecl", // MODULE-CHECK-SAME: scope: ![[MODULE:[0-9]+]], // MODULE-CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC" +// MODULE-CHECK: !DICompositeType(tag: DW_TAG_structure_type, +// MODULE-CHECK-SAME: name: "ObjCClass", +// MODULE-CHECK-SAME: scope: ![[MODULE]], -- 2.50.1