r183474 - ObjC Debug Info: Emit the names of accessors whenever they diverge from

Adrian Prantl aprantl at apple.com
Thu Jun 6 18:10:46 PDT 2013


Author: adrian
Date: Thu Jun  6 20:10:45 2013
New Revision: 183474

URL: http://llvm.org/viewvc/llvm-project?rev=183474&view=rev
Log:
ObjC Debug Info: Emit the names of accessors whenever they diverge from
the default names, not just when the isImplicit flag is set.

rdar://problem/14035789

Added:
    cfe/trunk/test/CodeGenObjC/debug-info-property-accessors.m
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=183474&r1=183473&r2=183474&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun  6 20:10:45 2013
@@ -1451,6 +1451,36 @@ llvm::DIType CGDebugInfo::CreateType(con
   return getOrCreateType(Ty->getBaseType(), Unit);
 }
 
+
+/// \return true if Getter has the default name for the property PD.
+static bool hasDefaultGetterName(const ObjCPropertyDecl *PD,
+                                 const ObjCMethodDecl *Getter) {
+  assert(PD);
+  if (!Getter)
+    return true;
+
+  assert(Getter->getDeclName().isObjCZeroArgSelector());
+  return PD->getName() ==
+    Getter->getDeclName().getObjCSelector().getNameForSlot(0);
+}
+
+/// \return true if Setter has the default name for the property PD.
+static bool hasDefaultSetterName(const ObjCPropertyDecl *PD,
+                                 const ObjCMethodDecl *Setter) {
+  assert(PD);
+  if (!Setter)
+    return true;
+
+  assert(Setter->getDeclName().isObjCOneArgSelector());
+  // Construct a setter name like SelectorTable::constructSetterName()
+  // does, but without entering it into the table.
+  SmallString<100> DefaultName("set");
+  DefaultName += PD->getName();
+  DefaultName[3] = toUppercase(DefaultName[3]);
+  return DefaultName ==
+    Setter->getDeclName().getObjCSelector().getNameForSlot(0);
+}
+
 /// CreateType - get objective-c interface type.
 llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
                                      llvm::DIFile Unit) {
@@ -1524,9 +1554,9 @@ llvm::DIType CGDebugInfo::CreateType(con
     llvm::MDNode *PropertyNode =
       DBuilder.createObjCProperty(PD->getName(),
                                   PUnit, PLine,
-                                  (Getter && Getter->isImplicit()) ? "" :
+                                  hasDefaultGetterName(PD, Getter) ? "" :
                                   getSelectorName(PD->getGetterName()),
-                                  (Setter && Setter->isImplicit()) ? "" :
+                                  hasDefaultSetterName(PD, Setter) ? "" :
                                   getSelectorName(PD->getSetterName()),
                                   PD->getPropertyAttributes(),
                                   getOrCreateType(PD->getType(), PUnit));
@@ -1598,9 +1628,9 @@ llvm::DIType CGDebugInfo::CreateType(con
           PropertyNode =
             DBuilder.createObjCProperty(PD->getName(),
                                         PUnit, PLine,
-                                        (Getter && Getter->isImplicit()) ? "" :
+                                        hasDefaultGetterName(PD, Getter) ? "" :
                                         getSelectorName(PD->getGetterName()),
-                                        (Setter && Setter->isImplicit()) ? "" :
+                                        hasDefaultSetterName(PD, Setter) ? "" :
                                         getSelectorName(PD->getSetterName()),
                                         PD->getPropertyAttributes(),
                                         getOrCreateType(PD->getType(), PUnit));

Added: cfe/trunk/test/CodeGenObjC/debug-info-property-accessors.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-property-accessors.m?rev=183474&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-property-accessors.m (added)
+++ cfe/trunk/test/CodeGenObjC/debug-info-property-accessors.m Thu Jun  6 20:10:45 2013
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -emit-llvm -x objective-c -g -triple x86_64-apple-macosx10.8.0 %s -o - | FileCheck %s
+//
+// rdar://problem/14035789
+//
+// Ensure we emit the names of explicit/renamed accessors even if they
+// are defined later in the implementation section.
+//
+// CHECK: metadata !{i32 {{.*}}, metadata !"blah", {{.*}} metadata !"isBlah", metadata !"", {{.*}}} ; [ DW_TAG_APPLE_property ] [blah]
+
+ at class NSString;
+extern void NSLog(NSString *format, ...);
+typedef signed char BOOL;
+
+#define YES             ((BOOL)1)
+#define NO              ((BOOL)0)
+
+typedef unsigned int NSUInteger;
+
+ at protocol NSObject
+ at end
+
+ at interface NSObject <NSObject>
+- (id)init;
++ (id)alloc;
+ at end
+
+ at interface Bar : NSObject
+ at property int normal_property;
+ at property (getter=isBlah, setter=setBlah:) BOOL blah;
+ at end
+
+ at implementation Bar
+ at synthesize normal_property;
+
+- (BOOL) isBlah
+{
+  return YES;
+}
+- (void) setBlah: (BOOL) newBlah
+{
+  NSLog (@"Speak up, I didn't catch that.");
+}
+ at end
+
+int
+main ()
+{
+  Bar *my_bar = [[Bar alloc] init];
+
+  if (my_bar.blah)
+    NSLog (@"It was true!!!");
+
+  my_bar.blah = NO;
+
+  return 0;
+}





More information about the cfe-commits mailing list