[cfe-commits] r131701 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenObjC/debug-property-synth.m

Devang Patel dpatel at apple.com
Thu May 19 16:37:41 PDT 2011


Author: dpatel
Date: Thu May 19 18:37:41 2011
New Revision: 131701

URL: http://llvm.org/viewvc/llvm-project?rev=131701&view=rev
Log:
Fix location of setter/getter synthesized for a property.

Added:
    cfe/trunk/test/CodeGenObjC/debug-property-synth.m
Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=131701&r1=131700&r2=131701&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu May 19 18:37:41 2011
@@ -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) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=131701&r1=131700&r2=131701&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu May 19 18:37:41 2011
@@ -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,

Added: cfe/trunk/test/CodeGenObjC/debug-property-synth.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-property-synth.m?rev=131701&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-property-synth.m (added)
+++ cfe/trunk/test/CodeGenObjC/debug-property-synth.m Thu May 19 18:37:41 2011
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+// Radar 9468526
+ at interface I {
+  int _p1;
+}
+ at property int p1;
+ at end
+
+ at implementation I
+ at synthesize p1 = _p1;
+ at end
+
+int main() {
+  I *myi;
+  myi.p1 = 2;
+  return 0;
+}
+
+// CHECK:       .loc    2 10 0





More information about the cfe-commits mailing list