Prefer C++-style casts.

This is based on Item 2 of "More Effective C++". In general, the C++ cast operators are more expressive and easy to find,
e.g. by grep. Using const_cast also shuts up some compiler warnings.
This commit is contained in:
kai
2012-08-03 06:32:23 +02:00
parent 2dbee75523
commit 311297b096
8 changed files with 18 additions and 18 deletions

View File

@@ -188,8 +188,8 @@ llvm::Type * IrTypeSArray::buildType()
llvm::Type * IrTypeSArray::sarray2llvm(Type * t)
{
assert(t->ty == Tsarray && "not static array type");
TypeSArray* tsa = (TypeSArray*)t;
dim = (uint64_t)tsa->dim->toUInteger();
TypeSArray* tsa = static_cast<TypeSArray*>(t);
dim = static_cast<uint64_t>(tsa->dim->toUInteger());
LLType* elemType = DtoType(t->nextOf());
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
@@ -256,10 +256,10 @@ llvm::Type* IrTypeVector::buildType()
llvm::Type* IrTypeVector::vector2llvm(Type* dt)
{
assert(dt->ty == Tvector && "not vector type");
TypeVector* tv = (TypeVector*)dt;
TypeVector* tv = static_cast<TypeVector*>(dt);
assert(tv->basetype->ty == Tsarray);
TypeSArray* tsa = (TypeSArray*)tv->basetype;
dim = (uint64_t)tsa->dim->toUInteger();
TypeSArray* tsa = static_cast<TypeSArray*>(tv->basetype);
dim = static_cast<uint64_t>(tsa->dim->toUInteger());
LLType* elemType = DtoType(tsa->next);
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());