]> granicus.if.org Git - clang/commitdiff
Module debugging: Also emit Objective-C interfaces forward declarations
authorAdrian Prantl <aprantl@apple.com>
Thu, 1 Oct 2015 16:57:02 +0000 (16:57 +0000)
committerAdrian Prantl <aprantl@apple.com>
Thu, 1 Oct 2015 16:57:02 +0000 (16:57 +0000)
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
test/Modules/Inputs/DebugObjC.h
test/Modules/ModuleDebugInfo.m

index d5ed7ea1d649739f66c0e65507667133ef9aef6b..b8c66eccba65033c3bee8afadb3a76bc05bd2eef 100644 (file)
@@ -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;
   }
index 8802f4b7b0665e64cd82191901c0aaf832e2841b..a44a362c928758c0d46e96a23db701e54ff954cb 100644 (file)
@@ -1,3 +1,5 @@
+@class FwdDecl;
+
 @interface ObjCClass {
   int ivar;
 }
index 8fac5f41f0f8f5f7401878de81d874ff8a599feb..5cfeb397f90d1caec808e4c81d595ca2ca46c038 100644 (file)
@@ -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]],