diff options
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 057f554ac6..f2a08b1c5c 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -282,7 +282,7 @@ public: llvm::Function *GenerateBlockFunction(const BlockExpr *Expr, const BlockInfo& Info, uint64_t &Size, uint64_t &Align, - llvm::SmallVector<ValueDecl *, 8> &subBlockDeclRefDecls); + llvm::SmallVector<const Expr *, 8> &subBlockDeclRefDecls); ImplicitParamDecl *BlockStructDecl; @@ -295,40 +295,21 @@ public: /// BlockDeclRefDecls - Decls from BlockDeclRefExprs in apperance order /// in a block literal. Decls without names are used for padding. - llvm::SmallVector<ValueDecl *, 8> BlockDeclRefDecls; + llvm::SmallVector<const Expr *, 8> BlockDeclRefDecls; /// BlockOffset - The offset in bytes for the next allocation of an /// imported block variable. uint64_t BlockOffset; /// BlockAlign - Maximal alignment needed for the Block expressed in bytes. uint64_t BlockAlign; - /// getBlockOffset - Offset for next allocated variable used in a BlockExpr. - uint64_t getBlockOffset(ValueDecl *D) { - uint64_t Size = getContext().getTypeSize(D->getType()) / 8; - uint64_t Align = getContext().getDeclAlignInBytes(D); - - assert ((Align > 0) && "alignment must be 1 byte or more"); - - uint64_t OldOffset = BlockOffset; - - // Ensure proper alignment, even if it means we have to have a gap - BlockOffset = llvm::RoundUpToAlignment(BlockOffset, Align); - BlockAlign = std::max(Align, BlockAlign); - - uint64_t Pad = BlockOffset - OldOffset; - llvm::ArrayType::get(llvm::Type::Int8Ty, Pad); - QualType PadTy = getContext().getConstantArrayType(getContext().CharTy, - llvm::APInt(32, Pad), - ArrayType::Normal, 0); - ValueDecl *PadDecl = VarDecl::Create(getContext(), 0, SourceLocation(), - 0, QualType(PadTy), VarDecl::None, SourceLocation()); - BlockDeclRefDecls.push_back(PadDecl); - BlockDeclRefDecls.push_back(D); - - BlockOffset += Size; - return BlockOffset-Size; - } - std::map<Decl*, uint64_t> BlockDecls; + /// getBlockOffset - Allocate an offset for the ValueDecl from a + /// BlockDeclRefExpr in a block literal (BlockExpr). + uint64_t getBlockOffset(const BlockDeclRefExpr *E); + + /// BlockDecls - Offsets for all Decls in BlockDeclRefExprs. + std::map<const Decl*, uint64_t> BlockDecls; + + llvm::Value *GetAddrOfBlockDecl(const BlockDeclRefExpr *E); void GenerateCode(const FunctionDecl *FD, llvm::Function *Fn); @@ -665,6 +646,8 @@ public: LValue EmitLValueForBitfield(llvm::Value* Base, FieldDecl* Field, unsigned CVRQualifiers); + LValue EmitBlockDeclRefLValue(const BlockDeclRefExpr *E); + LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E); LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E); |