Emit debug info for properites that are not backed by an ivar.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149995 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 5127159..47aaf43 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -1307,8 +1307,18 @@
     EltTys.push_back(InhTag);
   }
 
+  for (ObjCContainerDecl::prop_iterator I = ID->prop_begin(),
+         E = ID->prop_end(); I != E; ++I) {
+    const ObjCPropertyDecl *PD = *I;
+    llvm::MDNode *PropertyNode =
+      DBuilder.createObjCProperty(PD->getName(),
+				  getSelectorName(PD->getGetterName()),
+				  getSelectorName(PD->getSetterName()),
+				  PD->getPropertyAttributes());
+    EltTys.push_back(PropertyNode);
+  }
+
   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) {
@@ -1351,26 +1361,18 @@
     else if (Field->getAccessControl() == ObjCIvarDecl::Private)
       Flags = llvm::DIDescriptor::FlagPrivate;
 
-    StringRef PropertyName;
-    StringRef PropertyGetter;
-    StringRef PropertySetter;
-    unsigned PropertyAttributes = 0;
-    ObjCPropertyDecl *PD = NULL;
     llvm::MDNode *PropertyNode = NULL;
-    if (ImpD)
+    if (ObjCImplementationDecl *ImpD = ID->getImplementation()) {
       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();
-      PropertyNode =
-	DBuilder.createObjCProperty(PropertyName, PropertyGetter, 
-                                    PropertySetter,
-                                    PropertyAttributes);
-      EltTys.push_back(PropertyNode);
+          ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) {
+        if (ObjCPropertyDecl *PD = PImpD->getPropertyDecl()) {
+	  PropertyNode =
+	    DBuilder.createObjCProperty(PD->getName(),
+                                        getSelectorName(PD->getGetterName()),
+                                        getSelectorName(PD->getSetterName()),
+                                        PD->getPropertyAttributes());
+	}
+      }
     }
     FieldTy = DBuilder.createObjCIVar(FieldName, FieldDefUnit,
                                       FieldLine, FieldSize, FieldAlign,
diff --git a/test/CodeGenObjC/debug-info-property5.m b/test/CodeGenObjC/debug-info-property5.m
new file mode 100644
index 0000000..3521574
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-property5.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+// CHECK: AT_APPLE_property_getter
+// CHECK: AT_APPLE_property_setter
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
+
+@interface BaseClass2 
+{
+	int _baseInt;
+}
+- (int) myGetBaseInt;
+- (void) mySetBaseInt: (int) in_int;
+@property(getter=myGetBaseInt,setter=mySetBaseInt:) int baseInt;
+@end
+
+@implementation BaseClass2
+
+- (int) myGetBaseInt
+{
+        return _baseInt;
+}
+
+- (void) mySetBaseInt: (int) in_int
+{
+    _baseInt = 2 * in_int;
+}
+@end
+
+
+void foo(BaseClass2 *ptr) {}