1 //===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This contains code to emit Objective-C code as LLVM code.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "CGDebugInfo.h"
15 #include "CGObjCRuntime.h"
16 #include "CodeGenFunction.h"
17 #include "CodeGenModule.h"
18 #include "clang/AST/ASTContext.h"
19 #include "clang/AST/DeclObjC.h"
20 #include "clang/AST/StmtObjC.h"
21 #include "clang/Basic/Diagnostic.h"
22 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/Target/TargetData.h"
24 using namespace clang;
25 using namespace CodeGen;
26 
27 /// Emits an instance of NSConstantString representing the object.
28 llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E)
29 {
30   llvm::Constant *C =
31       CGM.getObjCRuntime().GenerateConstantString(E->getString());
32   // FIXME: This bitcast should just be made an invariant on the Runtime.
33   return llvm::ConstantExpr::getBitCast(C, ConvertType(E->getType()));
34 }
35 
36 /// Emit a selector.
37 llvm::Value *CodeGenFunction::EmitObjCSelectorExpr(const ObjCSelectorExpr *E) {
38   // Untyped selector.
39   // Note that this implementation allows for non-constant strings to be passed
40   // as arguments to @selector().  Currently, the only thing preventing this
41   // behaviour is the type checking in the front end.
42   return CGM.getObjCRuntime().GetSelector(Builder, E->getSelector());
43 }
44 
45 llvm::Value *CodeGenFunction::EmitObjCProtocolExpr(const ObjCProtocolExpr *E) {
46   // FIXME: This should pass the Decl not the name.
47   return CGM.getObjCRuntime().GenerateProtocolRef(Builder, E->getProtocol());
48 }
49 
50 
51 RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E,
52                                             ReturnValueSlot Return) {
53   // Only the lookup mechanism and first two arguments of the method
54   // implementation vary between runtimes.  We can get the receiver and
55   // arguments in generic code.
56 
57   CGObjCRuntime &Runtime = CGM.getObjCRuntime();
58   bool isSuperMessage = false;
59   bool isClassMessage = false;
60   ObjCInterfaceDecl *OID = 0;
61   // Find the receiver
62   llvm::Value *Receiver = 0;
63   switch (E->getReceiverKind()) {
64   case ObjCMessageExpr::Instance:
65     Receiver = EmitScalarExpr(E->getInstanceReceiver());
66     break;
67 
68   case ObjCMessageExpr::Class: {
69     const ObjCObjectType *ObjTy
70       = E->getClassReceiver()->getAs<ObjCObjectType>();
71     assert(ObjTy && "Invalid Objective-C class message send");
72     OID = ObjTy->getInterface();
73     assert(OID && "Invalid Objective-C class message send");
74     Receiver = Runtime.GetClass(Builder, OID);
75     isClassMessage = true;
76     break;
77   }
78 
79   case ObjCMessageExpr::SuperInstance:
80     Receiver = LoadObjCSelf();
81     isSuperMessage = true;
82     break;
83 
84   case ObjCMessageExpr::SuperClass:
85     Receiver = LoadObjCSelf();
86     isSuperMessage = true;
87     isClassMessage = true;
88     break;
89   }
90 
91   CallArgList Args;
92   EmitCallArgs(Args, E->getMethodDecl(), E->arg_begin(), E->arg_end());
93 
94   QualType ResultType =
95     E->getMethodDecl() ? E->getMethodDecl()->getResultType() : E->getType();
96 
97   if (isSuperMessage) {
98     // super is only valid in an Objective-C method
99     const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
100     bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext());
101     return Runtime.GenerateMessageSendSuper(*this, Return, ResultType,
102                                             E->getSelector(),
103                                             OMD->getClassInterface(),
104                                             isCategoryImpl,
105                                             Receiver,
106                                             isClassMessage,
107                                             Args,
108                                             E->getMethodDecl());
109   }
110 
111   return Runtime.GenerateMessageSend(*this, Return, ResultType,
112                                      E->getSelector(),
113                                      Receiver, Args, OID,
114                                      E->getMethodDecl());
115 }
116 
117 /// StartObjCMethod - Begin emission of an ObjCMethod. This generates
118 /// the LLVM function and sets the other context used by
119 /// CodeGenFunction.
120 void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
121                                       const ObjCContainerDecl *CD,
122                                       SourceLocation StartLoc) {
123   FunctionArgList args;
124   // Check if we should generate debug info for this method.
125   if (CGM.getModuleDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
126     DebugInfo = CGM.getModuleDebugInfo();
127 
128   llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD);
129 
130   const CGFunctionInfo &FI = CGM.getTypes().getFunctionInfo(OMD);
131   CGM.SetInternalFunctionAttributes(OMD, Fn, FI);
132 
133   args.push_back(OMD->getSelfDecl());
134   args.push_back(OMD->getCmdDecl());
135 
136   for (ObjCMethodDecl::param_iterator PI = OMD->param_begin(),
137        E = OMD->param_end(); PI != E; ++PI)
138     args.push_back(*PI);
139 
140   CurGD = OMD;
141 
142   StartFunction(OMD, OMD->getResultType(), Fn, FI, args, StartLoc);
143 }
144 
145 void CodeGenFunction::GenerateObjCGetterBody(ObjCIvarDecl *Ivar,
146                                              bool IsAtomic, bool IsStrong) {
147   LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
148                                 Ivar, 0);
149   llvm::Value *GetCopyStructFn =
150   CGM.getObjCRuntime().GetGetStructFunction();
151   CodeGenTypes &Types = CGM.getTypes();
152   // objc_copyStruct (ReturnValue, &structIvar,
153   //                  sizeof (Type of Ivar), isAtomic, false);
154   CallArgList Args;
155   RValue RV = RValue::get(Builder.CreateBitCast(ReturnValue, VoidPtrTy));
156   Args.add(RV, getContext().VoidPtrTy);
157   RV = RValue::get(Builder.CreateBitCast(LV.getAddress(), VoidPtrTy));
158   Args.add(RV, getContext().VoidPtrTy);
159   // sizeof (Type of Ivar)
160   CharUnits Size =  getContext().getTypeSizeInChars(Ivar->getType());
161   llvm::Value *SizeVal =
162   llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy),
163                          Size.getQuantity());
164   Args.add(RValue::get(SizeVal), getContext().LongTy);
165   llvm::Value *isAtomic =
166   llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy),
167                          IsAtomic ? 1 : 0);
168   Args.add(RValue::get(isAtomic), getContext().BoolTy);
169   llvm::Value *hasStrong =
170   llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy),
171                          IsStrong ? 1 : 0);
172   Args.add(RValue::get(hasStrong), getContext().BoolTy);
173   EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args,
174                                  FunctionType::ExtInfo()),
175            GetCopyStructFn, ReturnValueSlot(), Args);
176 }
177 
178 /// Generate an Objective-C method.  An Objective-C method is a C function with
179 /// its pointer, name, and types registered in the class struture.
180 void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
181   StartObjCMethod(OMD, OMD->getClassInterface(), OMD->getLocStart());
182   EmitStmt(OMD->getBody());
183   FinishFunction(OMD->getBodyRBrace());
184 }
185 
186 // FIXME: I wasn't sure about the synthesis approach. If we end up generating an
187 // AST for the whole body we can just fall back to having a GenerateFunction
188 // which takes the body Stmt.
189 
190 /// GenerateObjCGetter - Generate an Objective-C property getter
191 /// function. The given Decl must be an ObjCImplementationDecl. @synthesize
192 /// is illegal within a category.
193 void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
194                                          const ObjCPropertyImplDecl *PID) {
195   ObjCIvarDecl *Ivar = PID->getPropertyIvarDecl();
196   const ObjCPropertyDecl *PD = PID->getPropertyDecl();
197   bool IsAtomic =
198     !(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_nonatomic);
199   ObjCMethodDecl *OMD = PD->getGetterMethodDecl();
200   assert(OMD && "Invalid call to generate getter (empty method)");
201   StartObjCMethod(OMD, IMP->getClassInterface(), PID->getLocStart());
202 
203   // Determine if we should use an objc_getProperty call for
204   // this. Non-atomic properties are directly evaluated.
205   // atomic 'copy' and 'retain' properties are also directly
206   // evaluated in gc-only mode.
207   if (CGM.getLangOptions().getGCMode() != LangOptions::GCOnly &&
208       IsAtomic &&
209       (PD->getSetterKind() == ObjCPropertyDecl::Copy ||
210        PD->getSetterKind() == ObjCPropertyDecl::Retain)) {
211     llvm::Value *GetPropertyFn =
212       CGM.getObjCRuntime().GetPropertyGetFunction();
213 
214     if (!GetPropertyFn) {
215       CGM.ErrorUnsupported(PID, "Obj-C getter requiring atomic copy");
216       FinishFunction();
217       return;
218     }
219 
220     // Return (ivar-type) objc_getProperty((id) self, _cmd, offset, true).
221     // FIXME: Can't this be simpler? This might even be worse than the
222     // corresponding gcc code.
223     CodeGenTypes &Types = CGM.getTypes();
224     ValueDecl *Cmd = OMD->getCmdDecl();
225     llvm::Value *CmdVal = Builder.CreateLoad(LocalDeclMap[Cmd], "cmd");
226     QualType IdTy = getContext().getObjCIdType();
227     llvm::Value *SelfAsId =
228       Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy));
229     llvm::Value *Offset = EmitIvarOffset(IMP->getClassInterface(), Ivar);
230     llvm::Value *True =
231       llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 1);
232     CallArgList Args;
233     Args.add(RValue::get(SelfAsId), IdTy);
234     Args.add(RValue::get(CmdVal), Cmd->getType());
235     Args.add(RValue::get(Offset), getContext().getPointerDiffType());
236     Args.add(RValue::get(True), getContext().BoolTy);
237     // FIXME: We shouldn't need to get the function info here, the
238     // runtime already should have computed it to build the function.
239     RValue RV = EmitCall(Types.getFunctionInfo(PD->getType(), Args,
240                                                FunctionType::ExtInfo()),
241                          GetPropertyFn, ReturnValueSlot(), Args);
242     // We need to fix the type here. Ivars with copy & retain are
243     // always objects so we don't need to worry about complex or
244     // aggregates.
245     RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
246                                            Types.ConvertType(PD->getType())));
247     EmitReturnOfRValue(RV, PD->getType());
248   } else {
249     const llvm::Triple &Triple = getContext().Target.getTriple();
250     QualType IVART = Ivar->getType();
251     if (IsAtomic &&
252         IVART->isScalarType() &&
253         (Triple.getArch() == llvm::Triple::arm ||
254          Triple.getArch() == llvm::Triple::thumb) &&
255         (getContext().getTypeSizeInChars(IVART)
256          > CharUnits::fromQuantity(4)) &&
257         CGM.getObjCRuntime().GetGetStructFunction()) {
258       GenerateObjCGetterBody(Ivar, true, false);
259     }
260     else if (IsAtomic &&
261              (IVART->isScalarType() && !IVART->isRealFloatingType()) &&
262              Triple.getArch() == llvm::Triple::x86 &&
263              (getContext().getTypeSizeInChars(IVART)
264               > CharUnits::fromQuantity(4)) &&
265              CGM.getObjCRuntime().GetGetStructFunction()) {
266       GenerateObjCGetterBody(Ivar, true, false);
267     }
268     else if (IsAtomic &&
269              (IVART->isScalarType() && !IVART->isRealFloatingType()) &&
270              Triple.getArch() == llvm::Triple::x86_64 &&
271              (getContext().getTypeSizeInChars(IVART)
272               > CharUnits::fromQuantity(8)) &&
273              CGM.getObjCRuntime().GetGetStructFunction()) {
274       GenerateObjCGetterBody(Ivar, true, false);
275     }
276     else if (IVART->isAnyComplexType()) {
277       LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
278                                     Ivar, 0);
279       ComplexPairTy Pair = LoadComplexFromAddr(LV.getAddress(),
280                                                LV.isVolatileQualified());
281       StoreComplexToAddr(Pair, ReturnValue, LV.isVolatileQualified());
282     }
283     else if (hasAggregateLLVMType(IVART)) {
284       bool IsStrong = false;
285       if ((IsStrong = IvarTypeWithAggrGCObjects(IVART))
286           && CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect
287           && CGM.getObjCRuntime().GetGetStructFunction()) {
288         GenerateObjCGetterBody(Ivar, IsAtomic, IsStrong);
289       }
290       else {
291         const CXXRecordDecl *classDecl = IVART->getAsCXXRecordDecl();
292 
293         if (PID->getGetterCXXConstructor() &&
294             classDecl && !classDecl->hasTrivialDefaultConstructor()) {
295           ReturnStmt *Stmt =
296             new (getContext()) ReturnStmt(SourceLocation(),
297                                           PID->getGetterCXXConstructor(),
298                                           0);
299           EmitReturnStmt(*Stmt);
300         } else if (IsAtomic &&
301                    !IVART->isAnyComplexType() &&
302                    Triple.getArch() == llvm::Triple::x86 &&
303                    (getContext().getTypeSizeInChars(IVART)
304                     > CharUnits::fromQuantity(4)) &&
305                    CGM.getObjCRuntime().GetGetStructFunction()) {
306           GenerateObjCGetterBody(Ivar, true, false);
307         }
308         else if (IsAtomic &&
309                  !IVART->isAnyComplexType() &&
310                  Triple.getArch() == llvm::Triple::x86_64 &&
311                  (getContext().getTypeSizeInChars(IVART)
312                   > CharUnits::fromQuantity(8)) &&
313                  CGM.getObjCRuntime().GetGetStructFunction()) {
314           GenerateObjCGetterBody(Ivar, true, false);
315         }
316         else {
317           LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
318                                         Ivar, 0);
319           EmitAggregateCopy(ReturnValue, LV.getAddress(), IVART);
320         }
321       }
322     }
323     else {
324         LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
325                                     Ivar, 0);
326         if (PD->getType()->isReferenceType()) {
327           RValue RV = RValue::get(LV.getAddress());
328           EmitReturnOfRValue(RV, PD->getType());
329         }
330         else {
331           CodeGenTypes &Types = CGM.getTypes();
332           RValue RV = EmitLoadOfLValue(LV, IVART);
333           RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
334                                                Types.ConvertType(PD->getType())));
335           EmitReturnOfRValue(RV, PD->getType());
336         }
337     }
338   }
339 
340   FinishFunction();
341 }
342 
343 void CodeGenFunction::GenerateObjCAtomicSetterBody(ObjCMethodDecl *OMD,
344                                                    ObjCIvarDecl *Ivar) {
345   // objc_copyStruct (&structIvar, &Arg,
346   //                  sizeof (struct something), true, false);
347   llvm::Value *GetCopyStructFn =
348   CGM.getObjCRuntime().GetSetStructFunction();
349   CodeGenTypes &Types = CGM.getTypes();
350   CallArgList Args;
351   LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0);
352   RValue RV =
353     RValue::get(Builder.CreateBitCast(LV.getAddress(),
354                 Types.ConvertType(getContext().VoidPtrTy)));
355   Args.add(RV, getContext().VoidPtrTy);
356   llvm::Value *Arg = LocalDeclMap[*OMD->param_begin()];
357   llvm::Value *ArgAsPtrTy =
358   Builder.CreateBitCast(Arg,
359                       Types.ConvertType(getContext().VoidPtrTy));
360   RV = RValue::get(ArgAsPtrTy);
361   Args.add(RV, getContext().VoidPtrTy);
362   // sizeof (Type of Ivar)
363   CharUnits Size =  getContext().getTypeSizeInChars(Ivar->getType());
364   llvm::Value *SizeVal =
365   llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy),
366                          Size.getQuantity());
367   Args.add(RValue::get(SizeVal), getContext().LongTy);
368   llvm::Value *True =
369   llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 1);
370   Args.add(RValue::get(True), getContext().BoolTy);
371   llvm::Value *False =
372   llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 0);
373   Args.add(RValue::get(False), getContext().BoolTy);
374   EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args,
375                                  FunctionType::ExtInfo()),
376            GetCopyStructFn, ReturnValueSlot(), Args);
377 }
378 
379 static bool
380 IvarAssignHasTrvialAssignment(const ObjCPropertyImplDecl *PID,
381                               QualType IvarT) {
382   bool HasTrvialAssignment = true;
383   if (PID->getSetterCXXAssignment()) {
384     const CXXRecordDecl *classDecl = IvarT->getAsCXXRecordDecl();
385     HasTrvialAssignment =
386       (!classDecl || classDecl->hasTrivialCopyAssignment());
387   }
388   return HasTrvialAssignment;
389 }
390 
391 /// GenerateObjCSetter - Generate an Objective-C property setter
392 /// function. The given Decl must be an ObjCImplementationDecl. @synthesize
393 /// is illegal within a category.
394 void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
395                                          const ObjCPropertyImplDecl *PID) {
396   ObjCIvarDecl *Ivar = PID->getPropertyIvarDecl();
397   const ObjCPropertyDecl *PD = PID->getPropertyDecl();
398   ObjCMethodDecl *OMD = PD->getSetterMethodDecl();
399   assert(OMD && "Invalid call to generate setter (empty method)");
400   StartObjCMethod(OMD, IMP->getClassInterface(), PID->getLocStart());
401   const llvm::Triple &Triple = getContext().Target.getTriple();
402   QualType IVART = Ivar->getType();
403   bool IsCopy = PD->getSetterKind() == ObjCPropertyDecl::Copy;
404   bool IsAtomic =
405     !(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_nonatomic);
406 
407   // Determine if we should use an objc_setProperty call for
408   // this. Properties with 'copy' semantics always use it, as do
409   // non-atomic properties with 'release' semantics as long as we are
410   // not in gc-only mode.
411   if (IsCopy ||
412       (CGM.getLangOptions().getGCMode() != LangOptions::GCOnly &&
413        PD->getSetterKind() == ObjCPropertyDecl::Retain)) {
414     llvm::Value *SetPropertyFn =
415       CGM.getObjCRuntime().GetPropertySetFunction();
416 
417     if (!SetPropertyFn) {
418       CGM.ErrorUnsupported(PID, "Obj-C getter requiring atomic copy");
419       FinishFunction();
420       return;
421     }
422 
423     // Emit objc_setProperty((id) self, _cmd, offset, arg,
424     //                       <is-atomic>, <is-copy>).
425     // FIXME: Can't this be simpler? This might even be worse than the
426     // corresponding gcc code.
427     CodeGenTypes &Types = CGM.getTypes();
428     ValueDecl *Cmd = OMD->getCmdDecl();
429     llvm::Value *CmdVal = Builder.CreateLoad(LocalDeclMap[Cmd], "cmd");
430     QualType IdTy = getContext().getObjCIdType();
431     llvm::Value *SelfAsId =
432       Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy));
433     llvm::Value *Offset = EmitIvarOffset(IMP->getClassInterface(), Ivar);
434     llvm::Value *Arg = LocalDeclMap[*OMD->param_begin()];
435     llvm::Value *ArgAsId =
436       Builder.CreateBitCast(Builder.CreateLoad(Arg, "arg"),
437                             Types.ConvertType(IdTy));
438     llvm::Value *True =
439       llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 1);
440     llvm::Value *False =
441       llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 0);
442     CallArgList Args;
443     Args.add(RValue::get(SelfAsId), IdTy);
444     Args.add(RValue::get(CmdVal), Cmd->getType());
445     Args.add(RValue::get(Offset), getContext().getPointerDiffType());
446     Args.add(RValue::get(ArgAsId), IdTy);
447     Args.add(RValue::get(IsAtomic ? True : False),  getContext().BoolTy);
448     Args.add(RValue::get(IsCopy ? True : False), getContext().BoolTy);
449     // FIXME: We shouldn't need to get the function info here, the runtime
450     // already should have computed it to build the function.
451     EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args,
452                                    FunctionType::ExtInfo()),
453              SetPropertyFn,
454              ReturnValueSlot(), Args);
455   } else if (IsAtomic && hasAggregateLLVMType(IVART) &&
456              !IVART->isAnyComplexType() &&
457              IvarAssignHasTrvialAssignment(PID, IVART) &&
458              ((Triple.getArch() == llvm::Triple::x86 &&
459               (getContext().getTypeSizeInChars(IVART)
460                > CharUnits::fromQuantity(4))) ||
461               (Triple.getArch() == llvm::Triple::x86_64 &&
462               (getContext().getTypeSizeInChars(IVART)
463                > CharUnits::fromQuantity(8))))
464              && CGM.getObjCRuntime().GetSetStructFunction()) {
465           // objc_copyStruct (&structIvar, &Arg,
466           //                  sizeof (struct something), true, false);
467     GenerateObjCAtomicSetterBody(OMD, Ivar);
468   } else if (PID->getSetterCXXAssignment()) {
469     EmitIgnoredExpr(PID->getSetterCXXAssignment());
470   } else {
471     if (IsAtomic &&
472         IVART->isScalarType() &&
473         (Triple.getArch() == llvm::Triple::arm ||
474          Triple.getArch() == llvm::Triple::thumb) &&
475         (getContext().getTypeSizeInChars(IVART)
476           > CharUnits::fromQuantity(4)) &&
477         CGM.getObjCRuntime().GetGetStructFunction()) {
478       GenerateObjCAtomicSetterBody(OMD, Ivar);
479     }
480     else if (IsAtomic &&
481              (IVART->isScalarType() && !IVART->isRealFloatingType()) &&
482              Triple.getArch() == llvm::Triple::x86 &&
483              (getContext().getTypeSizeInChars(IVART)
484               > CharUnits::fromQuantity(4)) &&
485              CGM.getObjCRuntime().GetGetStructFunction()) {
486       GenerateObjCAtomicSetterBody(OMD, Ivar);
487     }
488     else if (IsAtomic &&
489              (IVART->isScalarType() && !IVART->isRealFloatingType()) &&
490              Triple.getArch() == llvm::Triple::x86_64 &&
491              (getContext().getTypeSizeInChars(IVART)
492               > CharUnits::fromQuantity(8)) &&
493              CGM.getObjCRuntime().GetGetStructFunction()) {
494       GenerateObjCAtomicSetterBody(OMD, Ivar);
495     }
496     else {
497       // FIXME: Find a clean way to avoid AST node creation.
498       SourceLocation Loc = PID->getLocStart();
499       ValueDecl *Self = OMD->getSelfDecl();
500       ObjCIvarDecl *Ivar = PID->getPropertyIvarDecl();
501       DeclRefExpr Base(Self, Self->getType(), VK_RValue, Loc);
502       ParmVarDecl *ArgDecl = *OMD->param_begin();
503       QualType T = ArgDecl->getType();
504       if (T->isReferenceType())
505         T = cast<ReferenceType>(T)->getPointeeType();
506       DeclRefExpr Arg(ArgDecl, T, VK_LValue, Loc);
507       ObjCIvarRefExpr IvarRef(Ivar, Ivar->getType(), Loc, &Base, true, true);
508 
509       // The property type can differ from the ivar type in some situations with
510       // Objective-C pointer types, we can always bit cast the RHS in these cases.
511       if (getContext().getCanonicalType(Ivar->getType()) !=
512           getContext().getCanonicalType(ArgDecl->getType())) {
513         ImplicitCastExpr ArgCasted(ImplicitCastExpr::OnStack,
514                                    Ivar->getType(), CK_BitCast, &Arg,
515                                    VK_RValue);
516         BinaryOperator Assign(&IvarRef, &ArgCasted, BO_Assign,
517                               Ivar->getType(), VK_RValue, OK_Ordinary, Loc);
518         EmitStmt(&Assign);
519       } else {
520         BinaryOperator Assign(&IvarRef, &Arg, BO_Assign,
521                               Ivar->getType(), VK_RValue, OK_Ordinary, Loc);
522         EmitStmt(&Assign);
523       }
524     }
525   }
526 
527   FinishFunction();
528 }
529 
530 // FIXME: these are stolen from CGClass.cpp, which is lame.
531 namespace {
532   struct CallArrayIvarDtor : EHScopeStack::Cleanup {
533     const ObjCIvarDecl *ivar;
534     llvm::Value *self;
535     CallArrayIvarDtor(const ObjCIvarDecl *ivar, llvm::Value *self)
536       : ivar(ivar), self(self) {}
537 
538     void Emit(CodeGenFunction &CGF, bool IsForEH) {
539       LValue lvalue =
540         CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), self, ivar, 0);
541 
542       QualType type = ivar->getType();
543       const ConstantArrayType *arrayType
544         = CGF.getContext().getAsConstantArrayType(type);
545       QualType baseType = CGF.getContext().getBaseElementType(arrayType);
546       const CXXRecordDecl *classDecl = baseType->getAsCXXRecordDecl();
547 
548       llvm::Value *base
549         = CGF.Builder.CreateBitCast(lvalue.getAddress(),
550                                     CGF.ConvertType(baseType)->getPointerTo());
551       CGF.EmitCXXAggrDestructorCall(classDecl->getDestructor(),
552                                     arrayType, base);
553     }
554   };
555 
556   struct CallIvarDtor : EHScopeStack::Cleanup {
557     const ObjCIvarDecl *ivar;
558     llvm::Value *self;
559     CallIvarDtor(const ObjCIvarDecl *ivar, llvm::Value *self)
560       : ivar(ivar), self(self) {}
561 
562     void Emit(CodeGenFunction &CGF, bool IsForEH) {
563       LValue lvalue =
564         CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), self, ivar, 0);
565 
566       QualType type = ivar->getType();
567       const CXXRecordDecl *classDecl = type->getAsCXXRecordDecl();
568 
569       CGF.EmitCXXDestructorCall(classDecl->getDestructor(),
570                                 Dtor_Complete, /*ForVirtualBase=*/false,
571                                 lvalue.getAddress());
572     }
573   };
574 }
575 
576 static void emitCXXDestructMethod(CodeGenFunction &CGF,
577                                   ObjCImplementationDecl *impl) {
578   CodeGenFunction::RunCleanupsScope scope(CGF);
579 
580   llvm::Value *self = CGF.LoadObjCSelf();
581 
582   ObjCInterfaceDecl *iface
583     = const_cast<ObjCInterfaceDecl*>(impl->getClassInterface());
584   for (ObjCIvarDecl *ivar = iface->all_declared_ivar_begin();
585        ivar; ivar = ivar->getNextIvar()) {
586     QualType type = ivar->getType();
587 
588     // Drill down to the base element type.
589     QualType baseType = type;
590     const ConstantArrayType *arrayType =
591       CGF.getContext().getAsConstantArrayType(baseType);
592     if (arrayType) baseType = CGF.getContext().getBaseElementType(arrayType);
593 
594     // Check whether the ivar is a destructible type.
595     QualType::DestructionKind destructKind = baseType.isDestructedType();
596     assert(destructKind == type.isDestructedType());
597 
598     switch (destructKind) {
599     case QualType::DK_none:
600       continue;
601 
602     case QualType::DK_cxx_destructor:
603       if (arrayType)
604         CGF.EHStack.pushCleanup<CallArrayIvarDtor>(NormalAndEHCleanup,
605                                                    ivar, self);
606       else
607         CGF.EHStack.pushCleanup<CallIvarDtor>(NormalAndEHCleanup,
608                                               ivar, self);
609       break;
610     }
611   }
612 
613   assert(scope.requiresCleanups() && "nothing to do in .cxx_destruct?");
614 }
615 
616 void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP,
617                                                  ObjCMethodDecl *MD,
618                                                  bool ctor) {
619   MD->createImplicitParams(CGM.getContext(), IMP->getClassInterface());
620   StartObjCMethod(MD, IMP->getClassInterface(), MD->getLocStart());
621 
622   // Emit .cxx_construct.
623   if (ctor) {
624     llvm::SmallVector<CXXCtorInitializer *, 8> IvarInitializers;
625     for (ObjCImplementationDecl::init_const_iterator B = IMP->init_begin(),
626            E = IMP->init_end(); B != E; ++B) {
627       CXXCtorInitializer *IvarInit = (*B);
628       FieldDecl *Field = IvarInit->getAnyMember();
629       ObjCIvarDecl  *Ivar = cast<ObjCIvarDecl>(Field);
630       LValue LV = EmitLValueForIvar(TypeOfSelfObject(),
631                                     LoadObjCSelf(), Ivar, 0);
632       EmitAggExpr(IvarInit->getInit(), AggValueSlot::forLValue(LV, true));
633     }
634     // constructor returns 'self'.
635     CodeGenTypes &Types = CGM.getTypes();
636     QualType IdTy(CGM.getContext().getObjCIdType());
637     llvm::Value *SelfAsId =
638       Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy));
639     EmitReturnOfRValue(RValue::get(SelfAsId), IdTy);
640 
641   // Emit .cxx_destruct.
642   } else {
643     emitCXXDestructMethod(*this, IMP);
644   }
645   FinishFunction();
646 }
647 
648 bool CodeGenFunction::IndirectObjCSetterArg(const CGFunctionInfo &FI) {
649   CGFunctionInfo::const_arg_iterator it = FI.arg_begin();
650   it++; it++;
651   const ABIArgInfo &AI = it->info;
652   // FIXME. Is this sufficient check?
653   return (AI.getKind() == ABIArgInfo::Indirect);
654 }
655 
656 bool CodeGenFunction::IvarTypeWithAggrGCObjects(QualType Ty) {
657   if (CGM.getLangOptions().getGCMode() == LangOptions::NonGC)
658     return false;
659   if (const RecordType *FDTTy = Ty.getTypePtr()->getAs<RecordType>())
660     return FDTTy->getDecl()->hasObjectMember();
661   return false;
662 }
663 
664 llvm::Value *CodeGenFunction::LoadObjCSelf() {
665   const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
666   return Builder.CreateLoad(LocalDeclMap[OMD->getSelfDecl()], "self");
667 }
668 
669 QualType CodeGenFunction::TypeOfSelfObject() {
670   const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
671   ImplicitParamDecl *selfDecl = OMD->getSelfDecl();
672   const ObjCObjectPointerType *PTy = cast<ObjCObjectPointerType>(
673     getContext().getCanonicalType(selfDecl->getType()));
674   return PTy->getPointeeType();
675 }
676 
677 LValue
678 CodeGenFunction::EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E) {
679   // This is a special l-value that just issues sends when we load or
680   // store through it.
681 
682   // For certain base kinds, we need to emit the base immediately.
683   llvm::Value *Base;
684   if (E->isSuperReceiver())
685     Base = LoadObjCSelf();
686   else if (E->isClassReceiver())
687     Base = CGM.getObjCRuntime().GetClass(Builder, E->getClassReceiver());
688   else
689     Base = EmitScalarExpr(E->getBase());
690   return LValue::MakePropertyRef(E, Base);
691 }
692 
693 static RValue GenerateMessageSendSuper(CodeGenFunction &CGF,
694                                        ReturnValueSlot Return,
695                                        QualType ResultType,
696                                        Selector S,
697                                        llvm::Value *Receiver,
698                                        const CallArgList &CallArgs) {
699   const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CGF.CurFuncDecl);
700   bool isClassMessage = OMD->isClassMethod();
701   bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext());
702   return CGF.CGM.getObjCRuntime()
703                 .GenerateMessageSendSuper(CGF, Return, ResultType,
704                                           S, OMD->getClassInterface(),
705                                           isCategoryImpl, Receiver,
706                                           isClassMessage, CallArgs);
707 }
708 
709 RValue CodeGenFunction::EmitLoadOfPropertyRefLValue(LValue LV,
710                                                     ReturnValueSlot Return) {
711   const ObjCPropertyRefExpr *E = LV.getPropertyRefExpr();
712   QualType ResultType = E->getGetterResultType();
713   Selector S;
714   if (E->isExplicitProperty()) {
715     const ObjCPropertyDecl *Property = E->getExplicitProperty();
716     S = Property->getGetterName();
717   } else {
718     const ObjCMethodDecl *Getter = E->getImplicitPropertyGetter();
719     S = Getter->getSelector();
720   }
721 
722   llvm::Value *Receiver = LV.getPropertyRefBaseAddr();
723 
724   // Accesses to 'super' follow a different code path.
725   if (E->isSuperReceiver())
726     return GenerateMessageSendSuper(*this, Return, ResultType,
727                                     S, Receiver, CallArgList());
728 
729   const ObjCInterfaceDecl *ReceiverClass
730     = (E->isClassReceiver() ? E->getClassReceiver() : 0);
731   return CGM.getObjCRuntime().
732              GenerateMessageSend(*this, Return, ResultType, S,
733                                  Receiver, CallArgList(), ReceiverClass);
734 }
735 
736 void CodeGenFunction::EmitStoreThroughPropertyRefLValue(RValue Src,
737                                                         LValue Dst) {
738   const ObjCPropertyRefExpr *E = Dst.getPropertyRefExpr();
739   Selector S = E->getSetterSelector();
740   QualType ArgType = E->getSetterArgType();
741 
742   // FIXME. Other than scalars, AST is not adequate for setter and
743   // getter type mismatches which require conversion.
744   if (Src.isScalar()) {
745     llvm::Value *SrcVal = Src.getScalarVal();
746     QualType DstType = getContext().getCanonicalType(ArgType);
747     const llvm::Type *DstTy = ConvertType(DstType);
748     if (SrcVal->getType() != DstTy)
749       Src =
750         RValue::get(EmitScalarConversion(SrcVal, E->getType(), DstType));
751   }
752 
753   CallArgList Args;
754   Args.add(Src, ArgType);
755 
756   llvm::Value *Receiver = Dst.getPropertyRefBaseAddr();
757   QualType ResultType = getContext().VoidTy;
758 
759   if (E->isSuperReceiver()) {
760     GenerateMessageSendSuper(*this, ReturnValueSlot(),
761                              ResultType, S, Receiver, Args);
762     return;
763   }
764 
765   const ObjCInterfaceDecl *ReceiverClass
766     = (E->isClassReceiver() ? E->getClassReceiver() : 0);
767 
768   CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(),
769                                            ResultType, S, Receiver, Args,
770                                            ReceiverClass);
771 }
772 
773 void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
774   llvm::Constant *EnumerationMutationFn =
775     CGM.getObjCRuntime().EnumerationMutationFunction();
776 
777   if (!EnumerationMutationFn) {
778     CGM.ErrorUnsupported(&S, "Obj-C fast enumeration for this runtime");
779     return;
780   }
781 
782   // The local variable comes into scope immediately.
783   AutoVarEmission variable = AutoVarEmission::invalid();
784   if (const DeclStmt *SD = dyn_cast<DeclStmt>(S.getElement()))
785     variable = EmitAutoVarAlloca(*cast<VarDecl>(SD->getSingleDecl()));
786 
787   CGDebugInfo *DI = getDebugInfo();
788   if (DI) {
789     DI->setLocation(S.getSourceRange().getBegin());
790     DI->EmitRegionStart(Builder);
791   }
792 
793   JumpDest LoopEnd = getJumpDestInCurrentScope("forcoll.end");
794   JumpDest AfterBody = getJumpDestInCurrentScope("forcoll.next");
795 
796   // Fast enumeration state.
797   QualType StateTy = getContext().getObjCFastEnumerationStateType();
798   llvm::Value *StatePtr = CreateMemTemp(StateTy, "state.ptr");
799   EmitNullInitialization(StatePtr, StateTy);
800 
801   // Number of elements in the items array.
802   static const unsigned NumItems = 16;
803 
804   // Fetch the countByEnumeratingWithState:objects:count: selector.
805   IdentifierInfo *II[] = {
806     &CGM.getContext().Idents.get("countByEnumeratingWithState"),
807     &CGM.getContext().Idents.get("objects"),
808     &CGM.getContext().Idents.get("count")
809   };
810   Selector FastEnumSel =
811     CGM.getContext().Selectors.getSelector(llvm::array_lengthof(II), &II[0]);
812 
813   QualType ItemsTy =
814     getContext().getConstantArrayType(getContext().getObjCIdType(),
815                                       llvm::APInt(32, NumItems),
816                                       ArrayType::Normal, 0);
817   llvm::Value *ItemsPtr = CreateMemTemp(ItemsTy, "items.ptr");
818 
819   // Emit the collection pointer.
820   llvm::Value *Collection = EmitScalarExpr(S.getCollection());
821 
822   // Send it our message:
823   CallArgList Args;
824 
825   // The first argument is a temporary of the enumeration-state type.
826   Args.add(RValue::get(StatePtr), getContext().getPointerType(StateTy));
827 
828   // The second argument is a temporary array with space for NumItems
829   // pointers.  We'll actually be loading elements from the array
830   // pointer written into the control state; this buffer is so that
831   // collections that *aren't* backed by arrays can still queue up
832   // batches of elements.
833   Args.add(RValue::get(ItemsPtr), getContext().getPointerType(ItemsTy));
834 
835   // The third argument is the capacity of that temporary array.
836   const llvm::Type *UnsignedLongLTy = ConvertType(getContext().UnsignedLongTy);
837   llvm::Constant *Count = llvm::ConstantInt::get(UnsignedLongLTy, NumItems);
838   Args.add(RValue::get(Count), getContext().UnsignedLongTy);
839 
840   // Start the enumeration.
841   RValue CountRV =
842     CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(),
843                                              getContext().UnsignedLongTy,
844                                              FastEnumSel,
845                                              Collection, Args);
846 
847   // The initial number of objects that were returned in the buffer.
848   llvm::Value *initialBufferLimit = CountRV.getScalarVal();
849 
850   llvm::BasicBlock *EmptyBB = createBasicBlock("forcoll.empty");
851   llvm::BasicBlock *LoopInitBB = createBasicBlock("forcoll.loopinit");
852 
853   llvm::Value *zero = llvm::Constant::getNullValue(UnsignedLongLTy);
854 
855   // If the limit pointer was zero to begin with, the collection is
856   // empty; skip all this.
857   Builder.CreateCondBr(Builder.CreateICmpEQ(initialBufferLimit, zero, "iszero"),
858                        EmptyBB, LoopInitBB);
859 
860   // Otherwise, initialize the loop.
861   EmitBlock(LoopInitBB);
862 
863   // Save the initial mutations value.  This is the value at an
864   // address that was written into the state object by
865   // countByEnumeratingWithState:objects:count:.
866   llvm::Value *StateMutationsPtrPtr =
867     Builder.CreateStructGEP(StatePtr, 2, "mutationsptr.ptr");
868   llvm::Value *StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr,
869                                                       "mutationsptr");
870 
871   llvm::Value *initialMutations =
872     Builder.CreateLoad(StateMutationsPtr, "forcoll.initial-mutations");
873 
874   // Start looping.  This is the point we return to whenever we have a
875   // fresh, non-empty batch of objects.
876   llvm::BasicBlock *LoopBodyBB = createBasicBlock("forcoll.loopbody");
877   EmitBlock(LoopBodyBB);
878 
879   // The current index into the buffer.
880   llvm::PHINode *index = Builder.CreatePHI(UnsignedLongLTy, 3, "forcoll.index");
881   index->addIncoming(zero, LoopInitBB);
882 
883   // The current buffer size.
884   llvm::PHINode *count = Builder.CreatePHI(UnsignedLongLTy, 3, "forcoll.count");
885   count->addIncoming(initialBufferLimit, LoopInitBB);
886 
887   // Check whether the mutations value has changed from where it was
888   // at start.  StateMutationsPtr should actually be invariant between
889   // refreshes.
890   StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr, "mutationsptr");
891   llvm::Value *currentMutations
892     = Builder.CreateLoad(StateMutationsPtr, "statemutations");
893 
894   llvm::BasicBlock *WasMutatedBB = createBasicBlock("forcoll.mutated");
895   llvm::BasicBlock *WasNotMutatedBB = createBasicBlock("forcoll.notmutated");
896 
897   Builder.CreateCondBr(Builder.CreateICmpEQ(currentMutations, initialMutations),
898                        WasNotMutatedBB, WasMutatedBB);
899 
900   // If so, call the enumeration-mutation function.
901   EmitBlock(WasMutatedBB);
902   llvm::Value *V =
903     Builder.CreateBitCast(Collection,
904                           ConvertType(getContext().getObjCIdType()),
905                           "tmp");
906   CallArgList Args2;
907   Args2.add(RValue::get(V), getContext().getObjCIdType());
908   // FIXME: We shouldn't need to get the function info here, the runtime already
909   // should have computed it to build the function.
910   EmitCall(CGM.getTypes().getFunctionInfo(getContext().VoidTy, Args2,
911                                           FunctionType::ExtInfo()),
912            EnumerationMutationFn, ReturnValueSlot(), Args2);
913 
914   // Otherwise, or if the mutation function returns, just continue.
915   EmitBlock(WasNotMutatedBB);
916 
917   // Initialize the element variable.
918   RunCleanupsScope elementVariableScope(*this);
919   bool elementIsVariable;
920   LValue elementLValue;
921   QualType elementType;
922   if (const DeclStmt *SD = dyn_cast<DeclStmt>(S.getElement())) {
923     // Initialize the variable, in case it's a __block variable or something.
924     EmitAutoVarInit(variable);
925 
926     const VarDecl* D = cast<VarDecl>(SD->getSingleDecl());
927     DeclRefExpr tempDRE(const_cast<VarDecl*>(D), D->getType(),
928                         VK_LValue, SourceLocation());
929     elementLValue = EmitLValue(&tempDRE);
930     elementType = D->getType();
931     elementIsVariable = true;
932   } else {
933     elementLValue = LValue(); // suppress warning
934     elementType = cast<Expr>(S.getElement())->getType();
935     elementIsVariable = false;
936   }
937   const llvm::Type *convertedElementType = ConvertType(elementType);
938 
939   // Fetch the buffer out of the enumeration state.
940   // TODO: this pointer should actually be invariant between
941   // refreshes, which would help us do certain loop optimizations.
942   llvm::Value *StateItemsPtr =
943     Builder.CreateStructGEP(StatePtr, 1, "stateitems.ptr");
944   llvm::Value *EnumStateItems =
945     Builder.CreateLoad(StateItemsPtr, "stateitems");
946 
947   // Fetch the value at the current index from the buffer.
948   llvm::Value *CurrentItemPtr =
949     Builder.CreateGEP(EnumStateItems, index, "currentitem.ptr");
950   llvm::Value *CurrentItem = Builder.CreateLoad(CurrentItemPtr);
951 
952   // Cast that value to the right type.
953   CurrentItem = Builder.CreateBitCast(CurrentItem, convertedElementType,
954                                       "currentitem");
955 
956   // Make sure we have an l-value.  Yes, this gets evaluated every
957   // time through the loop.
958   if (!elementIsVariable)
959     elementLValue = EmitLValue(cast<Expr>(S.getElement()));
960 
961   EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue, elementType);
962 
963   // If we do have an element variable, this assignment is the end of
964   // its initialization.
965   if (elementIsVariable)
966     EmitAutoVarCleanups(variable);
967 
968   // Perform the loop body, setting up break and continue labels.
969   BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody));
970   {
971     RunCleanupsScope Scope(*this);
972     EmitStmt(S.getBody());
973   }
974   BreakContinueStack.pop_back();
975 
976   // Destroy the element variable now.
977   elementVariableScope.ForceCleanup();
978 
979   // Check whether there are more elements.
980   EmitBlock(AfterBody.getBlock());
981 
982   llvm::BasicBlock *FetchMoreBB = createBasicBlock("forcoll.refetch");
983 
984   // First we check in the local buffer.
985   llvm::Value *indexPlusOne
986     = Builder.CreateAdd(index, llvm::ConstantInt::get(UnsignedLongLTy, 1));
987 
988   // If we haven't overrun the buffer yet, we can continue.
989   Builder.CreateCondBr(Builder.CreateICmpULT(indexPlusOne, count),
990                        LoopBodyBB, FetchMoreBB);
991 
992   index->addIncoming(indexPlusOne, AfterBody.getBlock());
993   count->addIncoming(count, AfterBody.getBlock());
994 
995   // Otherwise, we have to fetch more elements.
996   EmitBlock(FetchMoreBB);
997 
998   CountRV =
999     CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(),
1000                                              getContext().UnsignedLongTy,
1001                                              FastEnumSel,
1002                                              Collection, Args);
1003 
1004   // If we got a zero count, we're done.
1005   llvm::Value *refetchCount = CountRV.getScalarVal();
1006 
1007   // (note that the message send might split FetchMoreBB)
1008   index->addIncoming(zero, Builder.GetInsertBlock());
1009   count->addIncoming(refetchCount, Builder.GetInsertBlock());
1010 
1011   Builder.CreateCondBr(Builder.CreateICmpEQ(refetchCount, zero),
1012                        EmptyBB, LoopBodyBB);
1013 
1014   // No more elements.
1015   EmitBlock(EmptyBB);
1016 
1017   if (!elementIsVariable) {
1018     // If the element was not a declaration, set it to be null.
1019 
1020     llvm::Value *null = llvm::Constant::getNullValue(convertedElementType);
1021     elementLValue = EmitLValue(cast<Expr>(S.getElement()));
1022     EmitStoreThroughLValue(RValue::get(null), elementLValue, elementType);
1023   }
1024 
1025   if (DI) {
1026     DI->setLocation(S.getSourceRange().getEnd());
1027     DI->EmitRegionEnd(Builder);
1028   }
1029 
1030   EmitBlock(LoopEnd.getBlock());
1031 }
1032 
1033 void CodeGenFunction::EmitObjCAtTryStmt(const ObjCAtTryStmt &S) {
1034   CGM.getObjCRuntime().EmitTryStmt(*this, S);
1035 }
1036 
1037 void CodeGenFunction::EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S) {
1038   CGM.getObjCRuntime().EmitThrowStmt(*this, S);
1039 }
1040 
1041 void CodeGenFunction::EmitObjCAtSynchronizedStmt(
1042                                               const ObjCAtSynchronizedStmt &S) {
1043   CGM.getObjCRuntime().EmitSynchronizedStmt(*this, S);
1044 }
1045 
1046 CGObjCRuntime::~CGObjCRuntime() {}
1047