r266937 - Module Debugging: Emit the canonical debug info for Objective-C classes
Adrian Prantl via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 20 16:59:37 PDT 2016
Author: adrian
Date: Wed Apr 20 18:59:32 2016
New Revision: 266937
URL: http://llvm.org/viewvc/llvm-project?rev=266937&view=rev
Log:
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>
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.m
cfe/trunk/test/Modules/Inputs/DebugObjC.h
cfe/trunk/test/Modules/ModuleDebugInfo.m
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=266937&r1=266936&r2=266937&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Apr 20 18:59:32 2016
@@ -1664,8 +1664,11 @@ llvm::DIType *CGDebugInfo::CreateType(co
if (!ID)
return nullptr;
- // Return a forward declaration if this type was imported from a clang module.
- if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition())
+ // Return a forward declaration if this type was imported from a clang module,
+ // 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,
ID->getName(),
getDeclContextDescriptor(ID), Unit, 0);
Modified: cfe/trunk/test/Modules/ExtDebugInfo.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.m?rev=266937&r1=266936&r2=266937&view=diff
==============================================================================
--- cfe/trunk/test/Modules/ExtDebugInfo.m (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.m Wed Apr 20 18:59:32 2016
@@ -18,6 +18,11 @@
@import DebugObjC;
#endif
+ at implementation ObjCClassWithPrivateIVars {
+ int hidden_ivar;
+}
+ at end
+
TypedefUnion tdu;
TypedefEnum tde;
TypedefStruct tds;
@@ -29,9 +34,16 @@ int foo(ObjCClass *c) {
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-SAME: type: ![[GLOBAL_UNION:[0-9]+]]
-// CHECK: ![[MOD:.*]] = !DIModule(scope: null, name: "DebugObjC
// CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,
// CHECK-SAME: elements: !{{[0-9]+}})
Modified: cfe/trunk/test/Modules/Inputs/DebugObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugObjC.h?rev=266937&r1=266936&r2=266937&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/DebugObjC.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugObjC.h Wed Apr 20 18:59:32 2016
@@ -1,3 +1,4 @@
+// -*- ObjC -*-
@class FwdDecl;
@interface ObjCClass {
@@ -9,6 +10,11 @@
@property int property;
@end
+ at interface ObjCClassWithPrivateIVars {
+ int public_ivar;
+}
+ at end
+
@interface ObjCClass (Category)
- categoryMethod;
@end
Modified: cfe/trunk/test/Modules/ModuleDebugInfo.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.m?rev=266937&r1=266936&r2=266937&view=diff
==============================================================================
--- cfe/trunk/test/Modules/ModuleDebugInfo.m (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.m Wed Apr 20 18:59:32 2016
@@ -33,13 +33,13 @@
// CHECK: ![[TD_ENUM:.*]] = !DICompositeType(tag: DW_TAG_enumeration_type,
// CHECK-NOT: name:
// CHECK-SAME: elements:
-// CHECK-SAME: )
// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]",
// CHECK-SAME: scope: ![[MODULE]],
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
// CHECK-SAME: scope: ![[MODULE]],
+// CHECK-SAME: elements
// The forward declaration should not be in the module scope.
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
@@ -47,13 +47,16 @@
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
// 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-SAME: elements:
// CHECK: ![[TD_UNION:.*]] = distinct !DICompositeType(tag: DW_TAG_union_type,
// CHECK-NOT: name:
// CHECK-SAME: elements:
-// CHECK-SAME: )
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion",
// CHECK-SAME: baseType: ![[TD_UNION]])
More information about the cfe-commits
mailing list