blob: f61e0bcd39cd2fcc2b2a5534de14b0a318aa9a61 [file] [log] [blame]
Anders Carlssond2a889b2009-02-12 00:39:25 +00001//===--- CGBlocks.cpp - Emit LLVM Code for declarations -------------------===//
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 blocks.
11//
12//===----------------------------------------------------------------------===//
13
14#include "CodeGenFunction.h"
15#include "CodeGenModule.h"
16#include "llvm/Module.h"
Anders Carlsson1f1cd392009-02-12 17:55:02 +000017#include "llvm/Target/TargetData.h"
Anders Carlssond2a889b2009-02-12 00:39:25 +000018
19#include <algorithm>
20
21using namespace clang;
22using namespace CodeGen;
23
Anders Carlsson1f1cd392009-02-12 17:55:02 +000024enum {
Mike Stumpb95bc002009-02-13 16:19:19 +000025 BLOCK_NEEDS_FREE = (1 << 24),
26 BLOCK_HAS_COPY_DISPOSE = (1 << 25),
27 BLOCK_HAS_CXX_OBJ = (1 << 26),
28 BLOCK_IS_GC = (1 << 27),
29 BLOCK_IS_GLOBAL = (1 << 28),
30 BLOCK_HAS_DESCRIPTOR = (1 << 29)
Anders Carlsson1f1cd392009-02-12 17:55:02 +000031};
32
Mike Stumpb95bc002009-02-13 16:19:19 +000033llvm::Constant *CodeGenFunction::BuildDescriptorBlockDecl() {
34 // FIXME: Push up.
35 bool BlockHasCopyDispose = false;
36
37 const llvm::PointerType *PtrToInt8Ty
38 = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
Mike Stumpff8f0872009-02-13 16:55:51 +000039 const llvm::Type *UnsignedLongTy
40 = CGM.getTypes().ConvertType(getContext().UnsignedLongTy);
Mike Stumpb95bc002009-02-13 16:19:19 +000041 llvm::Constant *C;
42 std::vector<llvm::Constant*> Elts;
43
44 // reserved
Mike Stumpff8f0872009-02-13 16:55:51 +000045 C = llvm::ConstantInt::get(UnsignedLongTy, 0);
Mike Stumpb95bc002009-02-13 16:19:19 +000046 Elts.push_back(C);
47
48 // Size
Mike Stumpac9b4df2009-02-13 17:03:17 +000049 int sz = CGM.getTargetData()
50 .getTypeStoreSizeInBits(CGM.getGenericBlockLiteralType()) / 8;
51 C = llvm::ConstantInt::get(UnsignedLongTy, sz);
Mike Stumpb95bc002009-02-13 16:19:19 +000052 Elts.push_back(C);
53
54 if (BlockHasCopyDispose) {
55 // copy_func_helper_decl
Mike Stumpff8f0872009-02-13 16:55:51 +000056 C = llvm::ConstantInt::get(UnsignedLongTy, 0);
Mike Stumpb95bc002009-02-13 16:19:19 +000057 C = llvm::ConstantExpr::getBitCast(C, PtrToInt8Ty);
58 Elts.push_back(C);
59
60 // destroy_func_decl
Mike Stumpff8f0872009-02-13 16:55:51 +000061 C = llvm::ConstantInt::get(UnsignedLongTy, 0);
Mike Stumpb95bc002009-02-13 16:19:19 +000062 C = llvm::ConstantExpr::getBitCast(C, PtrToInt8Ty);
63 Elts.push_back(C);
64 }
65
66 C = llvm::ConstantStruct::get(Elts);
67
68 // FIXME: Should be in module?
69 static int desc_unique_count;
70 char Name[32];
71 sprintf(Name, "__block_descriptor_tmp_%d", ++desc_unique_count);
72 C = new llvm::GlobalVariable(C->getType(), true,
73 llvm::GlobalValue::InternalLinkage,
74 C, Name, &CGM.getModule());
75 return C;
76}
77
Mike Stump5f87e9d2009-02-13 17:23:42 +000078llvm::Constant *CodeGenModule::getNSConcreteGlobalBlock() {
79 if (NSConcreteGlobalBlock)
80 return NSConcreteGlobalBlock;
81
82 const llvm::PointerType *PtrToInt8Ty
83 = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
84 // FIXME: Wee should have a CodeGenModule::AddRuntimeVariable that does the
85 // same thing as CreateRuntimeFunction if there's already a variable with
86 // the same name.
87 NSConcreteGlobalBlock
88 = new llvm::GlobalVariable(PtrToInt8Ty, false,
89 llvm::GlobalValue::ExternalLinkage,
90 0, "_NSConcreteGlobalBlock",
91 &getModule());
92
93 return NSConcreteGlobalBlock;
94}
95
Mike Stumpb95bc002009-02-13 16:19:19 +000096llvm::Constant *CodeGenFunction::BuildBlockLiteralTmp() {
97 // FIXME: Push up
98 bool BlockHasCopyDispose = false;
99 bool insideFunction = false;
100 bool BlockRefDeclList = false;
101 bool BlockByrefDeclList = false;
102
103 std::vector<llvm::Constant*> Elts;
104 llvm::Constant *C;
105
106 bool staticBlockTmp = (BlockRefDeclList == 0
107 && BlockByrefDeclList == 0);
108
109 {
110 // C = BuildBlockStructInitlist();
111 unsigned int flags = BLOCK_HAS_DESCRIPTOR;
112
113 if (BlockHasCopyDispose)
114 flags |= BLOCK_HAS_COPY_DISPOSE;
115
116 const llvm::PointerType *PtrToInt8Ty
117 = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
118 // FIXME: static? What if we start up a new, unrelated module?
119 // logically we want 1 per module.
Mike Stumpb95bc002009-02-13 16:19:19 +0000120 static llvm::Constant *NSConcreteStackBlock_decl
121 = new llvm::GlobalVariable(PtrToInt8Ty, false,
122 llvm::GlobalValue::ExternalLinkage,
123 0, "_NSConcreteStackBlock",
124 &CGM.getModule());
125 C = NSConcreteStackBlock_decl;
126 if (!insideFunction ||
127 (!BlockRefDeclList && !BlockByrefDeclList)) {
Mike Stump5f87e9d2009-02-13 17:23:42 +0000128 C = CGM.getNSConcreteGlobalBlock();
Mike Stumpb95bc002009-02-13 16:19:19 +0000129 flags |= BLOCK_IS_GLOBAL;
130 }
131 C = llvm::ConstantExpr::getBitCast(C, PtrToInt8Ty);
132 Elts.push_back(C);
133
134 // __flags
135 const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
136 CGM.getTypes().ConvertType(CGM.getContext().IntTy));
137 C = llvm::ConstantInt::get(IntTy, flags);
138 Elts.push_back(C);
139
140 // __reserved
141 C = llvm::ConstantInt::get(IntTy, 0);
142 Elts.push_back(C);
143
144 // __FuncPtr
145 // FIXME: Build this up.
146 Elts.push_back(C);
147
148 // __descriptor
149 Elts.push_back(BuildDescriptorBlockDecl());
150
151 // FIXME: Add block_original_ref_decl_list and block_byref_decl_list.
152 }
153
154 C = llvm::ConstantStruct::get(Elts);
155
156 char Name[32];
157 // FIXME: Boost in CGM?
158 static int global_unique_count;
159 sprintf(Name, "__block_holder_tmp_%d", ++global_unique_count);
160 C = new llvm::GlobalVariable(C->getType(), true,
161 llvm::GlobalValue::InternalLinkage,
162 C, Name, &CGM.getModule());
163 return C;
164}
165
166
167
168
Mike Stump95e54802009-02-13 15:16:56 +0000169const llvm::Type *CodeGenModule::getBlockDescriptorType() {
170 if (BlockDescriptorType)
171 return BlockDescriptorType;
172
Mike Stumpc4ae9632009-02-13 15:32:32 +0000173 const llvm::Type *UnsignedLongTy =
Mike Stump95e54802009-02-13 15:16:56 +0000174 getTypes().ConvertType(getContext().UnsignedLongTy);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000175
Mike Stump95e54802009-02-13 15:16:56 +0000176 // struct __block_descriptor {
177 // unsigned long reserved;
178 // unsigned long block_size;
179 // };
Mike Stumpc4ae9632009-02-13 15:32:32 +0000180 BlockDescriptorType = llvm::StructType::get(UnsignedLongTy,
181 UnsignedLongTy,
Mike Stump95e54802009-02-13 15:16:56 +0000182 NULL);
183
184 getModule().addTypeName("struct.__block_descriptor",
185 BlockDescriptorType);
186
187 return BlockDescriptorType;
Anders Carlssond2a889b2009-02-12 00:39:25 +0000188}
189
Mike Stump0dffa462009-02-13 15:25:34 +0000190const llvm::Type *
191CodeGenModule::getGenericBlockLiteralType() {
192 if (GenericBlockLiteralType)
193 return GenericBlockLiteralType;
194
Mike Stumpc4ae9632009-02-13 15:32:32 +0000195 const llvm::Type *Int8PtrTy =
Mike Stump0dffa462009-02-13 15:25:34 +0000196 llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000197
198 const llvm::Type *BlockDescPtrTy =
Mike Stump0dffa462009-02-13 15:25:34 +0000199 llvm::PointerType::getUnqual(getBlockDescriptorType());
Mike Stumpc4ae9632009-02-13 15:32:32 +0000200
Mike Stump7b7cd8b2009-02-13 16:01:35 +0000201 const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
202 getTypes().ConvertType(getContext().IntTy));
203
Mike Stump0dffa462009-02-13 15:25:34 +0000204 // struct __block_literal_generic {
205 // void *isa;
206 // int flags;
207 // int reserved;
208 // void (*invoke)(void *);
209 // struct __block_descriptor *descriptor;
210 // };
211 GenericBlockLiteralType = llvm::StructType::get(Int8PtrTy,
Mike Stump7b7cd8b2009-02-13 16:01:35 +0000212 IntTy,
213 IntTy,
Mike Stump0dffa462009-02-13 15:25:34 +0000214 Int8PtrTy,
215 BlockDescPtrTy,
216 NULL);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000217
Mike Stump0dffa462009-02-13 15:25:34 +0000218 getModule().addTypeName("struct.__block_literal_generic",
219 GenericBlockLiteralType);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000220
Mike Stump0dffa462009-02-13 15:25:34 +0000221 return GenericBlockLiteralType;
Anders Carlssond2a889b2009-02-12 00:39:25 +0000222}
223
Mike Stumpc4ae9632009-02-13 15:32:32 +0000224/// getBlockFunctionType - Given a BlockPointerType, will return the
Anders Carlssond2a889b2009-02-12 00:39:25 +0000225/// function type for the block, including the first block literal argument.
226static QualType getBlockFunctionType(ASTContext &Ctx,
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000227 const BlockPointerType *BPT) {
Anders Carlssond2a889b2009-02-12 00:39:25 +0000228 const FunctionTypeProto *FTy = cast<FunctionTypeProto>(BPT->getPointeeType());
Mike Stumpc4ae9632009-02-13 15:32:32 +0000229
Anders Carlssond2a889b2009-02-12 00:39:25 +0000230 llvm::SmallVector<QualType, 8> Types;
231 Types.push_back(Ctx.getPointerType(Ctx.VoidTy));
Mike Stumpc4ae9632009-02-13 15:32:32 +0000232
Anders Carlssond2a889b2009-02-12 00:39:25 +0000233 for (FunctionTypeProto::arg_type_iterator i = FTy->arg_type_begin(),
234 e = FTy->arg_type_end(); i != e; ++i)
235 Types.push_back(*i);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000236
Anders Carlssond2a889b2009-02-12 00:39:25 +0000237 return Ctx.getFunctionType(FTy->getResultType(),
Mike Stumpc4ae9632009-02-13 15:32:32 +0000238 &Types[0], Types.size(),
Anders Carlssond2a889b2009-02-12 00:39:25 +0000239 FTy->isVariadic(), 0);
240}
241
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000242RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
Mike Stumpc4ae9632009-02-13 15:32:32 +0000243 const BlockPointerType *BPT =
Anders Carlssond2a889b2009-02-12 00:39:25 +0000244 E->getCallee()->getType()->getAsBlockPointerType();
Mike Stumpc4ae9632009-02-13 15:32:32 +0000245
Anders Carlssond2a889b2009-02-12 00:39:25 +0000246 llvm::Value *Callee = EmitScalarExpr(E->getCallee());
247
248 // Get a pointer to the generic block literal.
249 const llvm::Type *BlockLiteralTy =
Mike Stump0dffa462009-02-13 15:25:34 +0000250 llvm::PointerType::getUnqual(CGM.getGenericBlockLiteralType());
Anders Carlssond2a889b2009-02-12 00:39:25 +0000251
252 // Bitcast the callee to a block literal.
Mike Stumpc4ae9632009-02-13 15:32:32 +0000253 llvm::Value *BlockLiteral =
Anders Carlssond2a889b2009-02-12 00:39:25 +0000254 Builder.CreateBitCast(Callee, BlockLiteralTy, "block.literal");
255
256 // Get the function pointer from the literal.
257 llvm::Value *FuncPtr = Builder.CreateStructGEP(BlockLiteral, 3, "tmp");
258 llvm::Value *Func = Builder.CreateLoad(FuncPtr, FuncPtr, "tmp");
259
260 // Cast the function pointer to the right type.
Mike Stumpc4ae9632009-02-13 15:32:32 +0000261 const llvm::Type *BlockFTy =
Anders Carlssond2a889b2009-02-12 00:39:25 +0000262 ConvertType(getBlockFunctionType(getContext(), BPT));
263 const llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy);
264 Func = Builder.CreateBitCast(Func, BlockFTyPtr);
265
Mike Stumpc4ae9632009-02-13 15:32:32 +0000266 BlockLiteral =
267 Builder.CreateBitCast(BlockLiteral,
Anders Carlssond2a889b2009-02-12 00:39:25 +0000268 llvm::PointerType::getUnqual(llvm::Type::Int8Ty),
269 "tmp");
Mike Stumpc4ae9632009-02-13 15:32:32 +0000270
Anders Carlssond2a889b2009-02-12 00:39:25 +0000271 // Add the block literal.
272 QualType VoidPtrTy = getContext().getPointerType(getContext().VoidTy);
273 CallArgList Args;
274 Args.push_back(std::make_pair(RValue::get(BlockLiteral), VoidPtrTy));
Mike Stumpc4ae9632009-02-13 15:32:32 +0000275
Anders Carlssond2a889b2009-02-12 00:39:25 +0000276 // And the rest of the arguments.
Mike Stumpc4ae9632009-02-13 15:32:32 +0000277 for (CallExpr::const_arg_iterator i = E->arg_begin(), e = E->arg_end();
Anders Carlssond2a889b2009-02-12 00:39:25 +0000278 i != e; ++i)
Mike Stumpc4ae9632009-02-13 15:32:32 +0000279 Args.push_back(std::make_pair(EmitAnyExprToTemp(*i),
Anders Carlssond2a889b2009-02-12 00:39:25 +0000280 i->getType()));
Mike Stumpc4ae9632009-02-13 15:32:32 +0000281
Anders Carlssond2a889b2009-02-12 00:39:25 +0000282 // And call the block.
Mike Stumpc4ae9632009-02-13 15:32:32 +0000283 return EmitCall(CGM.getTypes().getFunctionInfo(E->getType(), Args),
Anders Carlssond2a889b2009-02-12 00:39:25 +0000284 Func, Args);
285}
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000286
287llvm::Constant *CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *BE) {
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000288 // Generate the block descriptor.
289 const llvm::Type *UnsignedLongTy = Types.ConvertType(Context.UnsignedLongTy);
Mike Stump7b7cd8b2009-02-13 16:01:35 +0000290 const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
291 getTypes().ConvertType(getContext().IntTy));
Mike Stumpc4ae9632009-02-13 15:32:32 +0000292
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000293 llvm::Constant *DescriptorFields[2];
Mike Stumpc4ae9632009-02-13 15:32:32 +0000294
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000295 // Reserved
296 DescriptorFields[0] = llvm::Constant::getNullValue(UnsignedLongTy);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000297
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000298 // Block literal size. For global blocks we just use the size of the generic
299 // block literal struct.
Mike Stumpc4ae9632009-02-13 15:32:32 +0000300 uint64_t BlockLiteralSize =
Mike Stump0dffa462009-02-13 15:25:34 +0000301 TheTargetData.getTypeStoreSizeInBits(getGenericBlockLiteralType()) / 8;
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000302 DescriptorFields[1] = llvm::ConstantInt::get(UnsignedLongTy,BlockLiteralSize);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000303
304 llvm::Constant *DescriptorStruct =
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000305 llvm::ConstantStruct::get(&DescriptorFields[0], 2);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000306
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000307 llvm::GlobalVariable *Descriptor =
308 new llvm::GlobalVariable(DescriptorStruct->getType(), true,
Mike Stumpc4ae9632009-02-13 15:32:32 +0000309 llvm::GlobalVariable::InternalLinkage,
310 DescriptorStruct, "__block_descriptor_global",
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000311 &getModule());
Mike Stumpc4ae9632009-02-13 15:32:32 +0000312
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000313 // Generate the constants for the block literal.
314 llvm::Constant *LiteralFields[5];
Mike Stumpc4ae9632009-02-13 15:32:32 +0000315
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000316 CodeGenFunction::BlockInfo Info(0, "global");
317 llvm::Function *Fn = CodeGenFunction(*this).GenerateBlockFunction(BE, Info);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000318
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000319 // isa
Mike Stump5f87e9d2009-02-13 17:23:42 +0000320 LiteralFields[0] = getNSConcreteGlobalBlock();
Mike Stumpc4ae9632009-02-13 15:32:32 +0000321
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000322 // Flags
Mike Stumpb95bc002009-02-13 16:19:19 +0000323 LiteralFields[1] = llvm::ConstantInt::get(IntTy, BLOCK_IS_GLOBAL);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000324
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000325 // Reserved
Mike Stump7b7cd8b2009-02-13 16:01:35 +0000326 LiteralFields[2] = llvm::Constant::getNullValue(IntTy);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000327
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000328 // Function
329 LiteralFields[3] = Fn;
Mike Stumpc4ae9632009-02-13 15:32:32 +0000330
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000331 // Descriptor
332 LiteralFields[4] = Descriptor;
Mike Stumpc4ae9632009-02-13 15:32:32 +0000333
334 llvm::Constant *BlockLiteralStruct =
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000335 llvm::ConstantStruct::get(&LiteralFields[0], 5);
Mike Stumpc4ae9632009-02-13 15:32:32 +0000336
337 llvm::GlobalVariable *BlockLiteral =
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000338 new llvm::GlobalVariable(BlockLiteralStruct->getType(), true,
Mike Stumpc4ae9632009-02-13 15:32:32 +0000339 llvm::GlobalVariable::InternalLinkage,
340 BlockLiteralStruct, "__block_literal_global",
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000341 &getModule());
Mike Stumpc4ae9632009-02-13 15:32:32 +0000342
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000343 return BlockLiteral;
344}
345
346llvm::Function *CodeGenFunction::GenerateBlockFunction(const BlockExpr *Expr,
347 const BlockInfo& Info)
348{
Mike Stumpc4ae9632009-02-13 15:32:32 +0000349 const FunctionTypeProto *FTy =
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000350 cast<FunctionTypeProto>(Expr->getFunctionType());
Mike Stumpc4ae9632009-02-13 15:32:32 +0000351
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000352 FunctionArgList Args;
Mike Stumpc4ae9632009-02-13 15:32:32 +0000353
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000354 const BlockDecl *BD = Expr->getBlockDecl();
355
356 // FIXME: This leaks
Mike Stumpc4ae9632009-02-13 15:32:32 +0000357 ImplicitParamDecl *SelfDecl =
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000358 ImplicitParamDecl::Create(getContext(), 0,
359 SourceLocation(), 0,
360 getContext().getPointerType(getContext().VoidTy));
Mike Stumpc4ae9632009-02-13 15:32:32 +0000361
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000362 Args.push_back(std::make_pair(SelfDecl, SelfDecl->getType()));
Mike Stumpc4ae9632009-02-13 15:32:32 +0000363
364 for (BlockDecl::param_iterator i = BD->param_begin(),
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000365 e = BD->param_end(); i != e; ++i)
366 Args.push_back(std::make_pair(*e, (*e)->getType()));
Mike Stumpc4ae9632009-02-13 15:32:32 +0000367
368 const CGFunctionInfo &FI =
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000369 CGM.getTypes().getFunctionInfo(FTy->getResultType(), Args);
370
371 std::string Name = std::string("__block_function_") + Info.NameSuffix;
372
373 CodeGenTypes &Types = CGM.getTypes();
374 const llvm::FunctionType *LTy = Types.GetFunctionType(FI, FTy->isVariadic());
Mike Stumpc4ae9632009-02-13 15:32:32 +0000375
376 llvm::Function *Fn =
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000377 llvm::Function::Create(LTy, llvm::GlobalValue::InternalLinkage,
378 Name,
379 &CGM.getModule());
Mike Stumpc4ae9632009-02-13 15:32:32 +0000380
381 StartFunction(BD, FTy->getResultType(), Fn, Args,
Anders Carlsson1f1cd392009-02-12 17:55:02 +0000382 Expr->getBody()->getLocEnd());
383 EmitStmt(Expr->getBody());
384 FinishFunction(cast<CompoundStmt>(Expr->getBody())->getRBracLoc());
385
386 return Fn;
387}