void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
- // Aggregate assignment turns into llvm.memset.
- const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
- if (DestPtr->getType() != BP)
- DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
-
- // Get size and alignment info for this aggregate.
- std::pair<uint64_t, unsigned> TypeInfo = CGF.getContext().getTypeInfo(Ty);
-
- // FIXME: Handle variable sized types.
- const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth);
-
- Builder.CreateCall4(CGF.CGM.getMemSetFn(),
- DestPtr,
- llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty),
- // TypeInfo.first describes size in bits.
- llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
- llvm::ConstantInt::get(llvm::Type::Int32Ty,
- TypeInfo.second/8));
+ CGF.EmitMemSetToZero(DestPtr, Ty);
}
void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr,
#include "CodeGenModule.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
+#include "llvm/ADT/STLExtras.h"
using namespace clang;
using namespace CodeGen;
false, Args);
}
+void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
+{
+ ErrorUnsupported(&S, "for ... in statement");
+}
+
CGObjCRuntime::~CGObjCRuntime() {}
case Stmt::ObjCAtSynchronizedStmtClass:
ErrorUnsupported(S, "@synchronized statement");
break;
- case Stmt::ObjCForCollectionStmtClass:
- ErrorUnsupported(S, "for ... in statement");
+ case Stmt::ObjCForCollectionStmtClass:
+ EmitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(*S));
break;
}
}
return LabelIDs.insert(std::make_pair(L, LabelIDs.size())).first->second;
}
+void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty)
+{
+ const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+ if (DestPtr->getType() != BP)
+ DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
+
+ // Get size and alignment info for this aggregate.
+ std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty);
+
+ // FIXME: Handle variable sized types.
+ const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth);
+
+ Builder.CreateCall4(CGM.getMemSetFn(), DestPtr,
+ llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty),
+ // TypeInfo.first describes size in bits.
+ llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
+ llvm::ConstantInt::get(llvm::Type::Int32Ty,
+ TypeInfo.second/8));
+}
+
void CodeGenFunction::EmitIndirectSwitches() {
llvm::BasicBlock *Default;
unsigned GetIDForAddrOfLabel(const LabelStmt *L);
+ /// EmitMemSetToZero - Generate code to memset a value of the given type to 0;
+ void EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty);
+
//===--------------------------------------------------------------------===//
// Declaration Emission
//===--------------------------------------------------------------------===//
void EmitCaseStmtRange(const CaseStmt &S);
void EmitAsmStmt(const AsmStmt &S);
+ void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);
+
//===--------------------------------------------------------------------===//
// LValue Expression Emission
//===--------------------------------------------------------------------===//