Fix location of setter/getter synthesized for a property.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131701 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index ee0ee7b..28e7e42 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -118,7 +118,8 @@
 /// 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 @@
 
   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 @@
 /// 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 @@
     !(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 @@
   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 @@
     }
     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 @@
                                                  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) {
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 28f5629..9aa7903 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -1076,7 +1076,8 @@
   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,