Skip to content
Snippets Groups Projects
Commit 29dbb7b2 authored by Adrian Prantl's avatar Adrian Prantl
Browse files

Module Debugging: Emit the canonical debug info for Objective-C classes

in the compile unit that contains their implementation even if their
interface is declared in a module.

The private @implementation of an @interface may have additional
hidden ivars so we should not defer to the public version of the
type that is found in the module.

<rdar://problem/25541798>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266937 91177308-0d34-0410-b5e6-96231b3b80d8
parent e3eeb614
No related branches found
No related tags found
No related merge requests found
...@@ -1664,8 +1664,11 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, ...@@ -1664,8 +1664,11 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
if (!ID) if (!ID)
return nullptr; return nullptr;
// Return a forward declaration if this type was imported from a clang module. // Return a forward declaration if this type was imported from a clang module,
if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition()) // and this is not the compile unit with the implementation of the type (which
// may contain hidden ivars).
if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() &&
!ID->getImplementation())
return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
ID->getName(), ID->getName(),
getDeclContextDescriptor(ID), Unit, 0); getDeclContextDescriptor(ID), Unit, 0);
......
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
@import DebugObjC; @import DebugObjC;
#endif #endif
@implementation ObjCClassWithPrivateIVars {
int hidden_ivar;
}
@end
TypedefUnion tdu; TypedefUnion tdu;
TypedefEnum tde; TypedefEnum tde;
TypedefStruct tds; TypedefStruct tds;
...@@ -29,9 +34,16 @@ int foo(ObjCClass *c) { ...@@ -29,9 +34,16 @@ int foo(ObjCClass *c) {
return [c property]; return [c property];
} }
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
// CHECK-SAME: flags: DIFlagObjcClassComplete
// CHECK: ![[MOD:.*]] = !DIModule(scope: null, name: "DebugObjC
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "hidden_ivar",
// CHECK-SAME: flags: DIFlagPrivate)
// CHECK: !DIGlobalVariable(name: "GlobalUnion", // CHECK: !DIGlobalVariable(name: "GlobalUnion",
// CHECK-SAME: type: ![[GLOBAL_UNION:[0-9]+]] // CHECK-SAME: type: ![[GLOBAL_UNION:[0-9]+]]
// CHECK: ![[MOD:.*]] = !DIModule(scope: null, name: "DebugObjC
// CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type, // CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,
// CHECK-SAME: elements: !{{[0-9]+}}) // CHECK-SAME: elements: !{{[0-9]+}})
......
// -*- ObjC -*-
@class FwdDecl; @class FwdDecl;
@interface ObjCClass { @interface ObjCClass {
...@@ -9,6 +10,11 @@ ...@@ -9,6 +10,11 @@
@property int property; @property int property;
@end @end
@interface ObjCClassWithPrivateIVars {
int public_ivar;
}
@end
@interface ObjCClass (Category) @interface ObjCClass (Category)
- categoryMethod; - categoryMethod;
@end @end
......
...@@ -33,13 +33,13 @@ ...@@ -33,13 +33,13 @@
// CHECK: ![[TD_ENUM:.*]] = !DICompositeType(tag: DW_TAG_enumeration_type, // CHECK: ![[TD_ENUM:.*]] = !DICompositeType(tag: DW_TAG_enumeration_type,
// CHECK-NOT: name: // CHECK-NOT: name:
// CHECK-SAME: elements: // CHECK-SAME: elements:
// CHECK-SAME: )
// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]", // CHECK: !DISubprogram(name: "+[ObjCClass classMethod]",
// CHECK-SAME: scope: ![[MODULE]], // CHECK-SAME: scope: ![[MODULE]],
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
// CHECK-SAME: scope: ![[MODULE]], // CHECK-SAME: scope: ![[MODULE]],
// CHECK-SAME: elements
// The forward declaration should not be in the module scope. // The forward declaration should not be in the module scope.
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
...@@ -47,13 +47,16 @@ ...@@ -47,13 +47,16 @@
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
// CHECK-SAME: scope: ![[MODULE]], // CHECK-SAME: scope: ![[MODULE]],
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
// CHECK-SAME: scope: ![[MODULE]],
// CHECK-SAME: elements
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDeclared" // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDeclared"
// CHECK-SAME: elements: // CHECK-SAME: elements:
// CHECK: ![[TD_UNION:.*]] = distinct !DICompositeType(tag: DW_TAG_union_type, // CHECK: ![[TD_UNION:.*]] = distinct !DICompositeType(tag: DW_TAG_union_type,
// CHECK-NOT: name: // CHECK-NOT: name:
// CHECK-SAME: elements: // CHECK-SAME: elements:
// CHECK-SAME: )
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion", // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion",
// CHECK-SAME: baseType: ![[TD_UNION]]) // CHECK-SAME: baseType: ![[TD_UNION]])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment