aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-05-15 01:53:33 +0000
committerJohn McCall <rjmccall@apple.com>2011-05-15 01:53:33 +0000
commit0774cb84719f2aea3016493a2bbd9a02aa3e0541 (patch)
tree2ef33101309581581e0d43bb1b87291b9c5cd4a3 /lib/CodeGen/CGBlocks.cpp
parent1493e2369cb426da9d916949f45e62a6e6ac5ab4 (diff)
Use arrays and SmallVectors instead of std::vectors when building function
types. Also, cache a translation of 'void' in CGM and provide a ptrdiff_t alias. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r--lib/CodeGen/CGBlocks.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index c6bedd2846..f11d528e13 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -245,7 +245,7 @@ static CharUnits getLowBit(CharUnits v) {
}
static void initializeForBlockHeader(CodeGenModule &CGM, CGBlockInfo &info,
- std::vector<const llvm::Type*> &elementTypes) {
+ llvm::SmallVectorImpl<const llvm::Type*> &elementTypes) {
ASTContext &C = CGM.getContext();
// The header is basically a 'struct { void *; int; int; void *; void *; }'.
@@ -282,7 +282,7 @@ static void computeBlockInfo(CodeGenModule &CGM, CGBlockInfo &info) {
ASTContext &C = CGM.getContext();
const BlockDecl *block = info.getBlockDecl();
- std::vector<const llvm::Type*> elementTypes;
+ llvm::SmallVector<const llvm::Type*, 8> elementTypes;
initializeForBlockHeader(CGM, info, elementTypes);
if (!block->hasCaptures()) {
@@ -703,9 +703,8 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E,
BlockLiteral = Builder.CreateBitCast(BlockLiteral, VoidPtrTy, "tmp");
// Add the block literal.
- QualType VoidPtrTy = getContext().getPointerType(getContext().VoidTy);
CallArgList Args;
- Args.add(RValue::get(BlockLiteral), VoidPtrTy);
+ Args.add(RValue::get(BlockLiteral), getContext().VoidPtrTy);
QualType FnType = BPT->getPointeeType();
@@ -1499,29 +1498,29 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) {
QualType Ty = D->getType();
- std::vector<const llvm::Type *> Types;
+ llvm::SmallVector<const llvm::Type *, 8> types;
llvm::PATypeHolder ByRefTypeHolder = llvm::OpaqueType::get(getLLVMContext());
// void *__isa;
- Types.push_back(Int8PtrTy);
+ types.push_back(Int8PtrTy);
// void *__forwarding;
- Types.push_back(llvm::PointerType::getUnqual(ByRefTypeHolder));
+ types.push_back(llvm::PointerType::getUnqual(ByRefTypeHolder));
// int32_t __flags;
- Types.push_back(Int32Ty);
+ types.push_back(Int32Ty);
// int32_t __size;
- Types.push_back(Int32Ty);
+ types.push_back(Int32Ty);
bool HasCopyAndDispose = getContext().BlockRequiresCopying(Ty);
if (HasCopyAndDispose) {
/// void *__copy_helper;
- Types.push_back(Int8PtrTy);
+ types.push_back(Int8PtrTy);
/// void *__destroy_helper;
- Types.push_back(Int8PtrTy);
+ types.push_back(Int8PtrTy);
}
bool Packed = false;
@@ -1544,11 +1543,11 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) {
if (NumPaddingBytes > 0) {
const llvm::Type *Ty = llvm::Type::getInt8Ty(getLLVMContext());
// FIXME: We need a sema error for alignment larger than the minimum of
- // the maximal stack alignmint and the alignment of malloc on the system.
+ // the maximal stack alignment and the alignment of malloc on the system.
if (NumPaddingBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumPaddingBytes);
- Types.push_back(Ty);
+ types.push_back(Ty);
// We want a packed struct.
Packed = true;
@@ -1556,9 +1555,9 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) {
}
// T x;
- Types.push_back(ConvertTypeForMem(Ty));
+ types.push_back(ConvertTypeForMem(Ty));
- const llvm::Type *T = llvm::StructType::get(getLLVMContext(), Types, Packed);
+ const llvm::Type *T = llvm::StructType::get(getLLVMContext(), types, Packed);
cast<llvm::OpaqueType>(ByRefTypeHolder.get())->refineAbstractTypeTo(T);
CGM.getModule().addTypeName("struct.__block_byref_" + D->getNameAsString(),
@@ -1566,7 +1565,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) {
Info.first = ByRefTypeHolder.get();
- Info.second = Types.size() - 1;
+ Info.second = types.size() - 1;
return Info.first;
}