]> granicus.if.org Git - clang/commitdiff
Fix location of setter/getter synthesized for a property.
authorDevang Patel <dpatel@apple.com>
Thu, 19 May 2011 23:37:41 +0000 (23:37 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 19 May 2011 23:37:41 +0000 (23:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131701 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjC.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGenObjC/debug-property-synth.m [new file with mode: 0644]

index ee0ee7b94109ad2ba1fea1753e06a6bda9b03793..28e7e42885785c5ec4cf672b2e71bf6c0f780ba8 100644 (file)
@@ -118,7 +118,8 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E,
 /// the LLVM function and sets the other context used by
 /// CodeGenFunction.
 void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
-                                      const ObjCContainerDecl *CD) {
+                                      const ObjCContainerDecl *CD,
+                                      SourceLocation StartLoc) {
   FunctionArgList args;
   // Check if we should generate debug info for this method.
   if (CGM.getModuleDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
@@ -138,7 +139,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
 
   CurGD = OMD;
 
-  StartFunction(OMD, OMD->getResultType(), Fn, FI, args, OMD->getLocStart());
+  StartFunction(OMD, OMD->getResultType(), Fn, FI, args, StartLoc);
 }
 
 void CodeGenFunction::GenerateObjCGetterBody(ObjCIvarDecl *Ivar, 
@@ -177,7 +178,7 @@ void CodeGenFunction::GenerateObjCGetterBody(ObjCIvarDecl *Ivar,
 /// Generate an Objective-C method.  An Objective-C method is a C function with
 /// its pointer, name, and types registered in the class struture.
 void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
-  StartObjCMethod(OMD, OMD->getClassInterface());
+  StartObjCMethod(OMD, OMD->getClassInterface(), OMD->getLocStart());
   EmitStmt(OMD->getBody());
   FinishFunction(OMD->getBodyRBrace());
 }
@@ -197,7 +198,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
     !(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_nonatomic);
   ObjCMethodDecl *OMD = PD->getGetterMethodDecl();
   assert(OMD && "Invalid call to generate getter (empty method)");
-  StartObjCMethod(OMD, IMP->getClassInterface());
+  StartObjCMethod(OMD, IMP->getClassInterface(), PID->getLocStart());
   
   // Determine if we should use an objc_getProperty call for
   // this. Non-atomic properties are directly evaluated.
@@ -396,7 +397,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
   const ObjCPropertyDecl *PD = PID->getPropertyDecl();
   ObjCMethodDecl *OMD = PD->getSetterMethodDecl();
   assert(OMD && "Invalid call to generate setter (empty method)");
-  StartObjCMethod(OMD, IMP->getClassInterface());
+  StartObjCMethod(OMD, IMP->getClassInterface(), PID->getLocStart());
   const llvm::Triple &Triple = getContext().Target.getTriple();
   QualType IVART = Ivar->getType();
   bool IsCopy = PD->getSetterKind() == ObjCPropertyDecl::Copy;
@@ -494,7 +495,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
     }
     else {
       // FIXME: Find a clean way to avoid AST node creation.
-      SourceLocation Loc = PD->getLocation();
+      SourceLocation Loc = PID->getLocStart();
       ValueDecl *Self = OMD->getSelfDecl();
       ObjCIvarDecl *Ivar = PID->getPropertyIvarDecl();
       DeclRefExpr Base(Self, Self->getType(), VK_RValue, Loc);
@@ -616,7 +617,7 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP,
                                                  ObjCMethodDecl *MD,
                                                  bool ctor) {
   MD->createImplicitParams(CGM.getContext(), IMP->getClassInterface());
-  StartObjCMethod(MD, IMP->getClassInterface());
+  StartObjCMethod(MD, IMP->getClassInterface(), MD->getLocStart());
 
   // Emit .cxx_construct.
   if (ctor) {
index 28f5629554dda9256931f3e24d42cc095b56bfce..9aa7903ab79ca4328a95d0e6be776e3385d08d9c 100644 (file)
@@ -1076,7 +1076,8 @@ public:
   void GenerateObjCMethod(const ObjCMethodDecl *OMD);
 
   void StartObjCMethod(const ObjCMethodDecl *MD,
-                       const ObjCContainerDecl *CD);
+                       const ObjCContainerDecl *CD,
+                       SourceLocation StartLoc);
 
   /// GenerateObjCGetter - Synthesize an Objective-C property getter function.
   void GenerateObjCGetter(ObjCImplementationDecl *IMP,
diff --git a/test/CodeGenObjC/debug-property-synth.m b/test/CodeGenObjC/debug-property-synth.m
new file mode 100644 (file)
index 0000000..05852b7
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+// Radar 9468526
+@interface I {
+  int _p1;
+}
+@property int p1;
+@end
+
+@implementation I
+@synthesize p1 = _p1;
+@end
+
+int main() {
+  I *myi;
+  myi.p1 = 2;
+  return 0;
+}
+
+// CHECK:       .loc    2 10 0