diff --git a/ir/irclass.cpp b/ir/irclass.cpp index 698e5835..3d92881f 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -154,7 +154,7 @@ LLConstant * IrStruct::getVtblInit() size_t n = cd->vtbl.dim; for (size_t i = 1; i < n; i++) { - Dsymbol* dsym = (Dsymbol*)cd->vtbl.data[i]; + Dsymbol* dsym = static_cast(cd->vtbl.data[i]); assert(dsym && "null vtbl member"); FuncDeclaration* fd = dsym->isFuncDeclaration(); @@ -178,14 +178,14 @@ LLConstant * IrStruct::getVtblInit() for (size_t j = 1; j < n; j++) { if (j == i) continue; - FuncDeclaration *fd2 = ((Dsymbol *)cd->vtbl.data[j])->isFuncDeclaration(); + FuncDeclaration *fd2 = static_cast(cd->vtbl.data[j])->isFuncDeclaration(); if (!fd2->ident->equals(fd->ident)) continue; if (fd->leastAsSpecialized(fd2) || fd2->leastAsSpecialized(fd)) { if (global.params.warnings) { - TypeFunction *tf = (TypeFunction *)fd->type; + TypeFunction *tf = static_cast(fd->type); if (tf->ty == Tfunction) error("%s%s is hidden by %s\n", fd->toPrettyChars(), Parameter::argsTypesToChars(tf->parameters, tf->varargs), toChars()); else @@ -385,7 +385,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan size_t n = vtbl_array.dim; for (size_t i = 1; i < n; i++) { - Dsymbol* dsym = (Dsymbol*)vtbl_array.data[i]; + Dsymbol* dsym = static_cast(vtbl_array.data[i]); if (dsym == NULL) { // FIXME diff --git a/ir/irdsymbol.cpp b/ir/irdsymbol.cpp index 880c66ed..e0480aa8 100644 --- a/ir/irdsymbol.cpp +++ b/ir/irdsymbol.cpp @@ -64,7 +64,7 @@ bool IrDsymbol::isSet() IrVar* IrDsymbol::getIrVar() { assert(irGlobal || irLocal || irField); - return irGlobal ? (IrVar*)irGlobal : irLocal ? (IrVar*)irLocal : (IrVar*)irField; + return irGlobal ? static_cast(irGlobal) : irLocal ? static_cast(irLocal) : static_cast(irField); } llvm::Value*& IrDsymbol::getIrValue() { return getIrVar()->value; } diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index efb2e469..d9493e80 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -129,7 +129,7 @@ IrFunction::IrFunction(FuncDeclaration* fd) Type* t = fd->type->toBasetype(); assert(t->ty == Tfunction); - type = (TypeFunction*)t; + type = static_cast(t); func = NULL; allocapoint = NULL; diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index 5275d1f7..ef531a47 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -251,8 +251,8 @@ LLConstant * IrStruct::createStructInitializer(StructInitializer * si) n = si->vars.dim; for (size_t i = 0; i < n; i++) { - VarDeclaration* vd = (VarDeclaration*)si->vars.data[i]; - Initializer* ini = (Initializer*)si->value.data[i]; + VarDeclaration* vd = static_cast(si->vars.data[i]); + Initializer* ini = static_cast(si->value.data[i]); Loc loc = ini ? ini->loc : si->loc; size_t idx = datamap[i]; @@ -297,7 +297,7 @@ LLConstant * IrStruct::createStructInitializer(StructInitializer * si) if (vd) continue; - vd = (VarDeclaration*)aggrdecl->fields.data[i]; + vd = static_cast(aggrdecl->fields.data[i]); unsigned vd_begin = vd->offset; unsigned vd_end = vd_begin + vd->type->size(); diff --git a/ir/irtype.cpp b/ir/irtype.cpp index 27cec84d..45f60455 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -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(t); + dim = static_cast(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(dt); assert(tv->basetype->ty == Tsarray); - TypeSArray* tsa = (TypeSArray*)tv->basetype; - dim = (uint64_t)tsa->dim->toUInteger(); + TypeSArray* tsa = static_cast(tv->basetype); + dim = static_cast(tsa->dim->toUInteger()); LLType* elemType = DtoType(tsa->next); if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext())) elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext()); diff --git a/ir/irtypeclass.cpp b/ir/irtypeclass.cpp index f725ecf8..ebe61715 100644 --- a/ir/irtypeclass.cpp +++ b/ir/irtypeclass.cpp @@ -22,7 +22,7 @@ extern bool var_offset_sort_cb(const VarDeclaration* v1, const VarDeclaration* v IrTypeClass::IrTypeClass(ClassDeclaration* cd) : IrTypeAggr(cd), cd(cd), - tc((TypeClass*)cd->type) + tc(static_cast(cd->type)) { std::string vtbl_name(cd->toPrettyChars()); vtbl_name.append(".__vtbl"); @@ -161,7 +161,7 @@ void IrTypeClass::addBaseClassData( offset = vd->offset + vd->type->size(); // create ir field - vd->aggrIndex = (unsigned)field_index; + vd->aggrIndex = static_cast(field_index); ++field_index; } diff --git a/ir/irtypefunction.cpp b/ir/irtypefunction.cpp index 3ac0085a..6707d0d8 100644 --- a/ir/irtypefunction.cpp +++ b/ir/irtypefunction.cpp @@ -21,7 +21,7 @@ llvm::Type * IrTypeFunction::buildType() llvm::Type* IrTypeFunction::func2llvm(Type* dt) { llvm::Type* T; - TypeFunction* tf = (TypeFunction*)dt; + TypeFunction* tf = static_cast(dt); if (tf->funcdecl) T = DtoFunctionType(tf->funcdecl); else diff --git a/ir/irtypestruct.cpp b/ir/irtypestruct.cpp index 55b7d165..d49e0cc2 100644 --- a/ir/irtypestruct.cpp +++ b/ir/irtypestruct.cpp @@ -29,7 +29,7 @@ IrTypeAggr::IrTypeAggr(AggregateDeclaration * ad) IrTypeStruct::IrTypeStruct(StructDeclaration * sd) : IrTypeAggr(sd), sd(sd), - ts((TypeStruct*)sd->type) + ts(static_cast(sd->type)) { }