]> granicus.if.org Git - clang/commitdiff
Tighten check to match an ivar with corresponding property by using ObjCImplementatio...
authorDevang Patel <dpatel@apple.com>
Mon, 19 Sep 2011 18:54:16 +0000 (18:54 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 19 Sep 2011 18:54:16 +0000 (18:54 +0000)
Radar 10139522 - Part 1.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140038 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenObjC/debug-info-property2.m [new file with mode: 0644]

index 919c5f9940a17adf4e5f968c9f4078743e1d20a4..89e14bafd0baee82519cc86ed9f7054c7680955b 100644 (file)
@@ -1194,7 +1194,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
   }
 
   const ASTRecordLayout &RL = CGM.getContext().getASTObjCInterfaceLayout(ID);
-
+  ObjCImplementationDecl *ImpD = ID->getImplementation();
   unsigned FieldNo = 0;
   for (ObjCIvarDecl *Field = ID->all_declared_ivar_begin(); Field;
        Field = Field->getNextIvar(), ++FieldNo) {
@@ -1238,13 +1238,17 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
     StringRef PropertyGetter;
     StringRef PropertySetter;
     unsigned PropertyAttributes = 0;
-    if (ObjCPropertyDecl *PD =
-        ID->FindPropertyVisibleInPrimaryClass(Field->getIdentifier())) {
+    ObjCPropertyDecl *PD = NULL;
+    if (ImpD)
+      if (ObjCPropertyImplDecl *PImpD = 
+         ImpD->FindPropertyImplIvarDecl(Field->getIdentifier()))
+       PD = PImpD->getPropertyDecl();
+    if (PD) {
       PropertyName = PD->getName();
       PropertyGetter = getSelectorName(PD->getGetterName());
       PropertySetter = getSelectorName(PD->getSetterName());
       PropertyAttributes = PD->getPropertyAttributes();
-    }
+    } 
     FieldTy = DBuilder.createObjCIVar(FieldName, FieldDefUnit,
                                       FieldLine, FieldSize, FieldAlign,
                                       FieldOffset, Flags, FieldTy,
diff --git a/test/CodeGenObjC/debug-info-property2.m b/test/CodeGenObjC/debug-info-property2.m
new file mode 100644 (file)
index 0000000..4cd76c1
--- /dev/null
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+@interface C {
+  int _base;
+}
+@property int base;
+@end
+
+@implementation C
+@synthesize base = _base;
+@end
+
+void foo(C *cptr) {}