diff --git a/gen/aa.cpp b/gen/aa.cpp index 1816f764..1fc02f86 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -20,7 +20,7 @@ static LLValue* to_keyti(DValue* aa) { // keyti param assert(aa->type->toBasetype()->ty == Taarray); - TypeAArray * aatype = (TypeAArray*)aa->type->toBasetype(); + TypeAArray * aatype = static_cast(aa->type->toBasetype()); return DtoTypeInfoOf(aatype->index, false); } #else diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index 6df721f4..86e83efa 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -161,9 +161,9 @@ namespace { } } } else if (ty->ty == Tstruct) { - Array* fields = &((TypeStruct*) ty)->sym->fields; + Array* fields = &static_cast(ty)->sym->fields; for (size_t i = 0; i < fields->dim; i++) { - VarDeclaration* field = (VarDeclaration*) fields->data[i]; + VarDeclaration* field = static_cast(fields->data[i]); classifyType(accum, field->type, offset + field->offset); } } else { diff --git a/gen/arrays.cpp b/gen/arrays.cpp index b5adde87..0130c3a4 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -81,7 +81,7 @@ LLArrayType* DtoStaticArrayType(Type* t) { t = t->toBasetype(); assert(t->ty == Tsarray); - TypeSArray* tsa = (TypeSArray*)t; + TypeSArray* tsa = static_cast(t); Type* tnext = tsa->nextOf(); LLType* elemty = DtoType(tnext); @@ -196,7 +196,7 @@ bool arrayNeedsPostblit(Type *t) { t = DtoArrayElementType(t); if (t->ty == Tstruct) - return ((TypeStruct *)t)->sym->postblit != 0; + return static_cast(t)->sym->postblit != 0; return false; } @@ -270,8 +270,8 @@ LLType* DtoConstArrayInitializerType(ArrayInitializer* arrinit) if (arrty->ty != Tsarray) return DtoType(arrinit->type); - TypeSArray* tsa = (TypeSArray*)arrty; - size_t arrlen = (size_t)tsa->dim->toInteger(); + TypeSArray* tsa = static_cast(arrty); + size_t arrlen = static_cast(tsa->dim->toInteger()); // get elem type Type* elemty = arrty->nextOf(); @@ -295,7 +295,7 @@ LLType* DtoConstArrayInitializerType(ArrayInitializer* arrinit) for (size_t i = 0; i < arrinit->index.dim; i++) { // get index - Expression* idx = (Expression*)arrinit->index.data[i]; + Expression* idx = static_cast(arrinit->index.data[i]); // idx can be null, then it's just the next element if (idx) @@ -303,7 +303,7 @@ LLType* DtoConstArrayInitializerType(ArrayInitializer* arrinit) assert(j < arrlen); // get value - Initializer* val = (Initializer*)arrinit->value.data[i]; + Initializer* val = static_cast(arrinit->value.data[i]); assert(val); LLType* c = DtoConstInitializerType(elemty, val); @@ -355,8 +355,8 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit) // initialized elements in the value/index lists if (arrty->ty == Tsarray) { - TypeSArray* tsa = (TypeSArray*)arrty; - arrlen = (size_t)tsa->dim->toInteger(); + TypeSArray* tsa = static_cast(arrty); + arrlen = static_cast(tsa->dim->toInteger()); } // make sure the number of initializers is sane @@ -381,7 +381,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit) for (size_t i = 0; i < arrinit->index.dim; i++) { // get index - Expression* idx = (Expression*)arrinit->index.data[i]; + Expression* idx = static_cast(arrinit->index.data[i]); // idx can be null, then it's just the next element if (idx) @@ -389,7 +389,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit) assert(j < arrlen); // get value - Initializer* val = (Initializer*)arrinit->value.data[i]; + Initializer* val = static_cast(arrinit->value.data[i]); assert(val); // error check from dmd @@ -540,7 +540,7 @@ static bool isInitialized(Type* et) { // If it's a typedef with "= void" initializer then don't initialize. if (et->ty == Ttypedef) { Logger::println("Typedef: %s", et->toChars()); - TypedefDeclaration* tdd = ((TypeTypedef*)et)->sym; + TypedefDeclaration* tdd = static_cast(et)->sym; if (tdd && tdd->init && tdd->init->isVoidInitializer()) return false; } @@ -863,11 +863,11 @@ DSliceValue* DtoCatArrays(Type* arrayType, Expression* exp1, Expression* exp2) fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arraycatnT"); args.push_back(DtoSlicePtr(exp2->toElem(gIR))); - CatExp *ce = (CatExp*)exp1; + CatExp *ce = static_cast(exp1); do { args.push_back(DtoSlicePtr(ce->e2->toElem(gIR))); - ce = (CatExp *)ce->e1; + ce = static_cast(ce->e1); } while (ce->op == TOKcat); args.push_back(DtoSlicePtr(ce->toElem(gIR))); @@ -1234,7 +1234,7 @@ LLValue* DtoArrayLen(DValue* v) assert(!v->isSlice()); assert(!v->isNull()); assert(v->type->toBasetype()->ty == Tsarray); - TypeSArray *sarray = (TypeSArray*)v->type->toBasetype(); + TypeSArray *sarray = static_cast(v->type->toBasetype()); return DtoConstSize_t(sarray->dim->toUInteger()); } assert(0 && "unsupported array for len"); @@ -1317,7 +1317,7 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to) fatal(); } - uinteger_t len = ((TypeSArray*)fromtype)->dim->toUInteger(); + uinteger_t len = static_cast(fromtype)->dim->toUInteger(); rval2 = LLConstantInt::get(DtoSize_t(), len, false); if (fromtype->nextOf()->size() != totype->nextOf()->size()) rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0)); @@ -1337,7 +1337,7 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to) if (Logger::enabled()) Logger::cout() << "to sarray" << '\n'; - size_t tosize = ((TypeSArray*)totype)->dim->toInteger(); + size_t tosize = static_cast(totype)->dim->toInteger(); if (fromtype->ty == Tsarray) { LLValue* uval = u->getRVal(); diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index aa59f7db..be7da84e 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -528,7 +528,7 @@ void AsmBlockStatement::toIR(IRState* p) // do asm statements for (unsigned i=0; idim; i++) { - Statement* s = (Statement*)statements->data[i]; + Statement* s = static_cast(statements->data[i]); if (s) { s->toIR(p); } @@ -800,7 +800,7 @@ Statement *AsmBlockStatement::syntaxCopy() a->setDim(statements->dim); for (size_t i = 0; i < statements->dim; i++) { - Statement *s = (Statement *)statements->data[i]; + Statement *s = static_cast(statements->data[i]); if (s) s = s->syntaxCopy(); a->data[i] = s; @@ -842,7 +842,7 @@ void AsmBlockStatement::toNakedIR(IRState *p) // do asm statements for (unsigned i=0; idim; i++) { - Statement* s = (Statement*)statements->data[i]; + Statement* s = static_cast(statements->data[i]); if (s) s->toNakedIR(p); } } diff --git a/gen/classes.cpp b/gen/classes.cpp index 30c1296f..1ac63ced 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -272,11 +272,11 @@ DValue* DtoCastClass(DValue* val, Type* _to) // must be class/interface assert(to->ty == Tclass); - TypeClass* tc = (TypeClass*)to; + TypeClass* tc = static_cast(to); // from type Type* from = val->getType()->toBasetype(); - TypeClass* fc = (TypeClass*)from; + TypeClass* fc = static_cast(from); // x -> interface if (InterfaceDeclaration* it = tc->sym->isInterfaceDeclaration()) { @@ -372,7 +372,7 @@ DValue* DtoDynamicCastObject(DValue* val, Type* _to) assert(funcTy->getParamType(0) == obj->getType()); // ClassInfo c - TypeClass* to = (TypeClass*)_to->toBasetype(); + TypeClass* to = static_cast(_to->toBasetype()); to->sym->codegen(Type::sir); LLValue* cinfo = to->sym->ir.irStruct->getClassInfoSymbol(); @@ -436,7 +436,7 @@ DValue* DtoDynamicCastInterface(DValue* val, Type* _to) ptr = DtoBitCast(ptr, funcTy->getParamType(0)); // ClassInfo c - TypeClass* to = (TypeClass*)_to->toBasetype(); + TypeClass* to = static_cast(_to->toBasetype()); to->sym->codegen(Type::sir); LLValue* cinfo = to->sym->ir.irStruct->getClassInfoSymbol(); // unfortunately this is needed as the implementation of object differs somehow from the declaration @@ -638,7 +638,7 @@ static unsigned build_classinfo_flags(ClassDeclaration* cd) continue; for (size_t i = 0; i < cd2->members->dim; i++) { - Dsymbol *sm = (Dsymbol *)cd2->members->data[i]; + Dsymbol *sm = static_cast(cd2->members->data[i]); if (sm->isVarDeclaration() && !sm->isVarDeclaration()->isDataseg()) // is this enough? hasOffTi = true; //printf("sm = %s %s\n", sm->kind(), sm->toChars()); @@ -685,7 +685,7 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) LOG_SCOPE; assert(cd->type->ty == Tclass); - TypeClass* cdty = (TypeClass*)cd->type; + TypeClass* cdty = static_cast(cd->type); IrStruct* ir = cd->ir.irStruct; assert(ir); @@ -757,7 +757,7 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) b.push(build_class_dtor(cd)); // invariant - VarDeclaration* invVar = (VarDeclaration*)cinfo->fields.data[6]; + VarDeclaration* invVar = static_cast(cinfo->fields.data[6]); b.push_funcptr(cd->inv, invVar->type); // uint flags @@ -770,7 +770,7 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) b.push_funcptr(cd->aggDelete, Type::tvoid->pointerTo()); // offset typeinfo - VarDeclaration* offTiVar = (VarDeclaration*)cinfo->fields.data[9]; + VarDeclaration* offTiVar = static_cast(cinfo->fields.data[9]); #if GENERATE_OFFTI @@ -786,13 +786,13 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) #endif // GENERATE_OFFTI // default constructor - VarDeclaration* defConstructorVar = (VarDeclaration*)cinfo->fields.data[10]; + VarDeclaration* defConstructorVar = static_cast(cinfo->fields.data[10]); b.push_funcptr(cd->defaultCtor, defConstructorVar->type); #if DMDV2 // xgetMembers - VarDeclaration* xgetVar = (VarDeclaration*)cinfo->fields.data[11]; + VarDeclaration* xgetVar = static_cast(cinfo->fields.data[11]); b.push_funcptr(cd->findGetMembers(), xgetVar->type); #else diff --git a/gen/declarations.cpp b/gen/declarations.cpp index 4f0b2f70..84c11e8c 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -85,7 +85,7 @@ void TupleDeclaration::codegen(Ir* p) for (int i=0; i < n; ++i) { - DsymbolExp* exp = (DsymbolExp*)objects->data[i]; + DsymbolExp* exp = static_cast(objects->data[i]); assert(exp->op == TOKdsymbol); exp->s->codegen(p); } @@ -262,7 +262,7 @@ void TemplateInstance::codegen(Ir* p) { for (unsigned i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = static_cast(members->data[i]); s->codegen(p); } } @@ -276,7 +276,7 @@ void TemplateMixin::codegen(Ir* p) { for (unsigned i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = static_cast(members->data[i]); if (s->isVarDeclaration()) continue; s->codegen(p); @@ -293,7 +293,7 @@ void AttribDeclaration::codegen(Ir* p) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = static_cast(d->data[i]); s->codegen(p); } } @@ -309,12 +309,12 @@ void PragmaDeclaration::codegen(Ir* p) { assert(args && args->dim == 1); - Expression *e = (Expression *)args->data[0]; + Expression *e = static_cast(args->data[0]); assert(e->op == TOKstring); - StringExp *se = (StringExp *)e; - char *name = (char *)mem.malloc(se->len + 1); + StringExp *se = static_cast(e); + char *name = static_cast(mem.malloc(se->len + 1)); memcpy(name, se->string, se->len); name[se->len] = 0; obj_includelib(name); diff --git a/gen/functions.cpp b/gen/functions.cpp index 0342c452..287464dc 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -35,7 +35,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, // sanity check assert(type->ty == Tfunction); - TypeFunction* f = (TypeFunction*)type; + TypeFunction* f = static_cast(type); TargetABI* abi = (f->linkage == LINKintrinsic ? TargetABI::getIntrinsic() : gABI); // Tell the ABI we're resolving a new function type @@ -219,7 +219,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, static llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl) { - TypeFunction* f = (TypeFunction*)fdecl->type; + TypeFunction* f = static_cast(fdecl->type); LLFunctionType* fty = 0; // create new ir funcTy @@ -317,7 +317,7 @@ void DtoResolveFunction(FuncDeclaration* fdecl) Type *type = fdecl->type; // If errors occurred compiling it, such as bugzilla 6118 if (type && type->ty == Tfunction) { - Type *next = ((TypeFunction *)type)->next; + Type *next = static_cast(type)->next; if (!next || next->ty == Terror) return; } @@ -349,12 +349,12 @@ void DtoResolveFunction(FuncDeclaration* fdecl) fdecl->llvmInternal = LLVMintrinsic; DtoOverloadedIntrinsicName(tinst, tempdecl, fdecl->intrinsicName); fdecl->linkage = LINKintrinsic; - ((TypeFunction*)fdecl->type)->linkage = LINKintrinsic; + static_cast(fdecl->type)->linkage = LINKintrinsic; } else if (tempdecl->llvmInternal == LLVMinline_asm) { Logger::println("magic inline asm found"); - TypeFunction* tf = (TypeFunction*)fdecl->type; + TypeFunction* tf = static_cast(fdecl->type); if (tf->varargs != 1 || (fdecl->parameters && fdecl->parameters->dim != 0)) { error("invalid __asm declaration, must be a D style variadic with no explicit parameters"); @@ -469,7 +469,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) // get TypeFunction* Type* t = fdecl->type->toBasetype(); - TypeFunction* f = (TypeFunction*)t; + TypeFunction* f = static_cast(t); bool declareOnly = !mustDefineSymbol(fdecl); @@ -600,7 +600,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) if (fdecl->parameters && fdecl->parameters->dim > k) { int paramIndex = f->fty.reverseParams ? fdecl->parameters->dim-k-1 : k; - Dsymbol* argsym = (Dsymbol*)fdecl->parameters->data[paramIndex]; + Dsymbol* argsym = static_cast(fdecl->parameters->data[paramIndex]); VarDeclaration* argvd = argsym->isVarDeclaration(); assert(argvd); @@ -659,7 +659,7 @@ void DtoDefineFunction(FuncDeclaration* fd) fd->ir.irFunc->diSubprogram = DtoDwarfSubProgram(fd); Type* t = fd->type->toBasetype(); - TypeFunction* f = (TypeFunction*)t; + TypeFunction* f = static_cast(t); // assert(f->irtype); llvm::Function* func = fd->ir.irFunc->func; @@ -749,7 +749,7 @@ void DtoDefineFunction(FuncDeclaration* fd) assert(n == fd->parameters->dim); for (int i=0; i < n; ++i) { - Dsymbol* argsym = (Dsymbol*)fd->parameters->data[i]; + Dsymbol* argsym = static_cast(fd->parameters->data[i]); VarDeclaration* vd = argsym->isVarDeclaration(); assert(vd); @@ -904,7 +904,7 @@ llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl) ClassDeclaration* base = cd->baseClass; if (!base) break; - FuncDeclaration* f2 = base->findFunc(fdecl->ident, (TypeFunction*)fdecl->type); + FuncDeclaration* f2 = base->findFunc(fdecl->ident, static_cast(fdecl->type)); if (f2) { f = f2; cd = base; diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index f61f5913..625dbb7a 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -397,7 +397,7 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op) // FIXME: use 'rhs' for something !?! DtoAggrZeroInit(lhs->getLVal()); #if DMDV2 - TypeStruct *ts = (TypeStruct*) lhs->getType(); + TypeStruct *ts = static_cast(lhs->getType()); if (ts->sym->isNested() && ts->sym->vthis) DtoResolveNestedContext(loc, ts->sym, lhs->getLVal()); #endif @@ -770,7 +770,7 @@ DValue* DtoCastVector(Loc& loc, DValue* val, Type* to) Type* totype = to->toBasetype(); LLType* tolltype = DtoType(to); LLValue *vector = val->getRVal(); - TypeVector *type = (TypeVector *)val->getType()->toBasetype(); + TypeVector *type = static_cast(val->getType()->toBasetype()); if (totype->ty == Tsarray) { @@ -778,7 +778,7 @@ DValue* DtoCastVector(Loc& loc, DValue* val, Type* to) Logger::cout() << "src: " << *vector << "to type: " << *tolltype << '\n'; LLValue *array = DtoAlloca(to); - TypeSArray *st = (TypeSArray*)totype; + TypeSArray *st = static_cast(totype); for (int i = 0, n = st->dim->toInteger(); i < n; ++i) { LLValue *lelem = DtoExtractElement(vector, i); @@ -804,9 +804,9 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to) #if DMDV2 if (fromtype->ty == Taarray) - fromtype = ((TypeAArray*)fromtype)->getImpl()->type; + fromtype = static_cast(fromtype)->getImpl()->type; if (totype->ty == Taarray) - totype = ((TypeAArray*)totype)->getImpl()->type; + totype = static_cast(totype)->getImpl()->type; #endif if (fromtype->equals(totype)) @@ -1105,10 +1105,10 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) !!(ei = vd->init->isExpInitializer())) { if (ei->exp->op == TOKconstruct) { - AssignExp *ae = (AssignExp*)ei->exp; + AssignExp *ae = static_cast(ei->exp); if (ae->e2->op == TOKcall) { - CallExp *ce = (CallExp *)ae->e2; - TypeFunction *tf = (TypeFunction *)ce->e1->type->toBasetype(); + CallExp *ce = static_cast(ae->e2); + TypeFunction *tf = static_cast(ce->e1->type->toBasetype()); if (tf->ty == Tfunction && tf->fty.arg_sret) { vd->ir.irLocal->value = ce->toElem(gIR)->getLVal(); goto Lexit; @@ -1200,7 +1200,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) if (d) for (unsigned i=0; i < d->dim; ++i) { - DtoDeclarationExp((Dsymbol*)d->data[i]); + DtoDeclarationExp(static_cast(d->data[i])); } } // mixin declaration @@ -1209,7 +1209,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) Logger::println("TemplateMixin"); for (unsigned i=0; i < m->members->dim; ++i) { - Dsymbol* mdsym = (Dsymbol*)m->members->data[i]; + Dsymbol* mdsym = static_cast(m->members->data[i]); DtoDeclarationExp(mdsym); } } @@ -1225,7 +1225,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) assert(tupled->objects); for (unsigned i=0; i < tupled->objects->dim; ++i) { - DsymbolExp* exp = (DsymbolExp*)tupled->objects->data[i]; + DsymbolExp* exp = static_cast(tupled->objects->data[i]); DtoDeclarationExp(exp->s); } } @@ -1318,7 +1318,7 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr) LLType* DtoConstInitializerType(Type* type, Initializer* init) { if (type->ty == Ttypedef) { - TypeTypedef *td = (TypeTypedef*)type; + TypeTypedef *td = static_cast(type); if (td->sym->init) return DtoConstInitializerType(td->sym->basetype, td->sym->init); } @@ -1328,7 +1328,7 @@ LLType* DtoConstInitializerType(Type* type, Initializer* init) { if (!init) { - TypeSArray *tsa = (TypeSArray*)type; + TypeSArray *tsa = static_cast(type); LLType *llnext = DtoConstInitializerType(type->nextOf(), init); return LLArrayType::get(llnext, tsa->dim->toUInteger()); } @@ -1342,19 +1342,19 @@ LLType* DtoConstInitializerType(Type* type, Initializer* init) if (!init) { LdefaultInit: - TypeStruct *ts = (TypeStruct*)type; + TypeStruct *ts = static_cast(type); DtoResolveStruct(ts->sym); return ts->sym->ir.irStruct->getDefaultInit()->getType(); } else if (ExpInitializer* ex = init->isExpInitializer()) { if (ex->exp->op == TOKstructliteral) { - StructLiteralExp* le = (StructLiteralExp*)ex->exp; + StructLiteralExp* le = static_cast(ex->exp); if (!le->constType) le->constType = LLStructType::create(gIR->context(), std::string(type->toChars()) + "_init"); return le->constType; } else if (ex->exp->op == TOKvar) { - if (((VarExp*)ex->exp)->var->isStaticStructInitDeclaration()) + if (static_cast(ex->exp)->var->isStaticStructInitDeclaration()) goto LdefaultInit; } } @@ -1458,7 +1458,7 @@ static LLConstant* expand_to_sarray(Type *base, Expression* exp) if (t->equals(expbase)) break; assert(t->ty == Tsarray); - TypeSArray* tsa = (TypeSArray*)t; + TypeSArray* tsa = static_cast(t); dims.push_back(tsa->dim->toInteger()); assert(t->nextOf()); t = t->nextOf()->toBasetype(); @@ -1561,7 +1561,7 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s // for now use the size in bits of the first template param in the instance assert(ti->tdtypes.dim == 1); - Type* T = (Type*)ti->tdtypes.data[0]; + Type* T = static_cast(ti->tdtypes.data[0]); char prefix = T->isreal() ? 'f' : T->isintegral() ? 'i' : 0; if (!prefix) { @@ -1570,7 +1570,7 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s } char tmp[21]; // probably excessive, but covers a uint64_t - sprintf(tmp, "%lu", (unsigned long) gTargetData->getTypeSizeInBits(DtoType(T))); + sprintf(tmp, "%lu", static_cast(gTargetData->getTypeSizeInBits(DtoType(T)))); // replace # in name with bitsize name = td->intrinsicName; @@ -1689,7 +1689,7 @@ bool hasUnalignedFields(Type* t) } else if (t->ty != Tstruct) return false; - TypeStruct* ts = (TypeStruct*)t; + TypeStruct* ts = static_cast(t); if (ts->unaligned) return (ts->unaligned == 2); @@ -1699,7 +1699,7 @@ bool hasUnalignedFields(Type* t) ts->unaligned = 2; for (unsigned i = 0; i < sym->fields.dim; i++) { - VarDeclaration* f = (VarDeclaration*)sym->fields.data[i]; + VarDeclaration* f = static_cast(sym->fields.data[i]); unsigned a = f->type->alignsize() - 1; if (((f->offset + a) & ~a) != f->offset) return true; @@ -1799,7 +1799,7 @@ Type * stripModifiers( Type * type ) if (!t) { unsigned sz = type->sizeTy[type->ty]; - t = (Type *)malloc(sz); + t = static_cast(malloc(sz)); memcpy(t, type, sz); t->mod = 0; t->deco = NULL; @@ -1897,7 +1897,7 @@ void callPostblit(Loc &loc, Expression *exp, LLValue *val) Type *tb = exp->type->toBasetype(); if ((exp->op == TOKvar || exp->op == TOKdotvar || exp->op == TOKstar || exp->op == TOKthis) && tb->ty == Tstruct) - { StructDeclaration *sd = ((TypeStruct *)tb)->sym; + { StructDeclaration *sd = static_cast(tb)->sym; if (sd->postblit) { FuncDeclaration *fd = sd->postblit; diff --git a/gen/module.cpp b/gen/module.cpp index fc3ca84b..6ee6dd88 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -259,7 +259,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir) // process module members for (unsigned k=0; k < members->dim; k++) { - Dsymbol* dsym = (Dsymbol*)(members->data[k]); + Dsymbol* dsym = static_cast(members->data[k]); assert(dsym); dsym->codegen(sir); } @@ -377,7 +377,7 @@ void Module::genmoduleinfo() llvm::ArrayType* importedModulesTy = 0; for (size_t i = 0; i < aimports.dim; i++) { - Module *m = (Module *)aimports.data[i]; + Module *m = static_cast(aimports.data[i]); if (!m->needModuleInfo() || m == this) continue; @@ -405,7 +405,7 @@ void Module::genmoduleinfo() { Dsymbol *member; - member = (Dsymbol *)members->data[i]; + member = static_cast(members->data[i]); //printf("\tmember '%s'\n", member->toChars()); member->addLocalClass(&aclasses); } @@ -413,7 +413,7 @@ void Module::genmoduleinfo() std::vector classInits; for (size_t i = 0; i < aclasses.dim; i++) { - ClassDeclaration* cd = (ClassDeclaration*)aclasses.data[i]; + ClassDeclaration* cd = static_cast(aclasses.data[i]); cd->codegen(Type::sir); if (cd->isInterfaceDeclaration()) diff --git a/gen/naked.cpp b/gen/naked.cpp index 992d1e8d..15bd27e7 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -31,7 +31,7 @@ void CompoundStatement::toNakedIR(IRState *p) if (statements) for (unsigned i = 0; i < statements->dim; i++) { - Statement* s = (Statement*)statements->data[i]; + Statement* s = static_cast(statements->data[i]); if (s) s->toNakedIR(p); } } @@ -50,7 +50,7 @@ void ExpStatement::toNakedIR(IRState *p) return; } - DeclarationExp* d = (DeclarationExp*)exp; + DeclarationExp* d = static_cast(exp); VarDeclaration* vd = d->declaration->isVarDeclaration(); FuncDeclaration* fd = d->declaration->isFuncDeclaration(); EnumDeclaration* ed = d->declaration->isEnumDeclaration(); @@ -362,26 +362,26 @@ DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments assert(arguments->dim >= 2 && "invalid __asm call"); // get code param - Expression* e = (Expression*)arguments->data[0]; + Expression* e = static_cast(arguments->data[0]); Logger::println("code exp: %s", e->toChars()); - StringExp* se = (StringExp*)e; + StringExp* se = static_cast(e); if (e->op != TOKstring || se->sz != 1) { e->error("__asm code argument is not a char[] string literal"); fatal(); } - std::string code((char*)se->string, se->len); + std::string code(static_cast(se->string), se->len); // get constraints param - e = (Expression*)arguments->data[1]; + e = static_cast(arguments->data[1]); Logger::println("constraint exp: %s", e->toChars()); - se = (StringExp*)e; + se = static_cast(e); if (e->op != TOKstring || se->sz != 1) { e->error("__asm constraints argument is not a char[] string literal"); fatal(); } - std::string constraints((char*)se->string, se->len); + std::string constraints(static_cast(se->string), se->len); // build runtime arguments size_t n = arguments->dim; @@ -393,7 +393,7 @@ DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments for (size_t i = 2; i < n; i++) { - e = (Expression*)arguments->data[i]; + e = static_cast(arguments->data[i]); args.push_back(e->toElem(gIR)->getRVal()); argtypes.push_back(args.back()->getType()); } @@ -415,7 +415,7 @@ DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments // make a copy llvm::Value* mem = DtoAlloca(type, ".__asm_tuple_ret"); - TypeStruct* ts = (TypeStruct*)type; + TypeStruct* ts = static_cast(type); size_t n = ts->sym->fields.dim; for (size_t i = 0; i < n; i++) { diff --git a/gen/nested.cpp b/gen/nested.cpp index 9d713698..1e4213ab 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -411,7 +411,7 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) { size_t nnest = fd->closureVars.dim; for (size_t i = 0; i < nnest; ++i) { - VarDeclaration* vd = (VarDeclaration*)fd->closureVars.data[i]; + VarDeclaration* vd = static_cast(fd->closureVars.data[i]); fd->nestedVars.insert(vd); } } diff --git a/gen/pragma.cpp b/gen/pragma.cpp index d6ed8217..d9270c59 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -13,9 +13,9 @@ static bool parseStringExp(Expression* e, std::string& res) StringExp *s = NULL; e = e->optimize(WANTvalue); - if (e->op == TOKstring && (s = (StringExp *)e)) + if (e->op == TOKstring && (s = static_cast(e))) { - char* str = (char*)s->string; + char* str = static_cast(s->string); res = str; return true; } @@ -42,7 +42,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) { "bitop.bts", LLVMbitop_bts }, }; - Expression* expr = (Expression *)args->data[0]; + Expression* expr = static_cast(args->data[0]); expr = expr->semantic(sc); if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) { @@ -197,7 +197,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) // pragma(atomic_rmw, "string") { templdecl(s) } else if (ident == Id::atomic_rmw) { - Expression* expr = (Expression *)args->data[0]; + Expression* expr = static_cast(args->data[0]); expr = expr->semantic(sc); if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) { @@ -210,7 +210,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) // pragma(ldc, "string") { templdecl(s) } else if (ident == Id::ldc) { - Expression* expr = (Expression *)args->data[0]; + Expression* expr = static_cast(args->data[0]); expr = expr->semantic(sc); if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) { @@ -264,7 +264,7 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s, fd->llvmInternal = llvm_internal; fd->intrinsicName = arg1str; fd->linkage = LINKintrinsic; - ((TypeFunction*)fd->type)->linkage = LINKintrinsic; + static_cast(fd->type)->linkage = LINKintrinsic; } else if (TemplateDeclaration* td = s->isTemplateDeclaration()) { diff --git a/gen/rttibuilder.cpp b/gen/rttibuilder.cpp index 52cb6ce1..6a8e3eeb 100644 --- a/gen/rttibuilder.cpp +++ b/gen/rttibuilder.cpp @@ -18,7 +18,7 @@ RTTIBuilder::RTTIBuilder(AggregateDeclaration* base_class) base_class->codegen(Type::sir); base = base_class; - basetype = (TypeClass*)base->type; + basetype = static_cast(base->type); baseir = base->ir.irStruct; assert(baseir && "no IrStruct for TypeInfo base class"); diff --git a/gen/statements.cpp b/gen/statements.cpp index 428a0379..c9212c74 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -38,7 +38,7 @@ void CompoundStatement::toIR(IRState* p) for (unsigned i=0; idim; i++) { - Statement* s = (Statement*)statements->data[i]; + Statement* s = static_cast(statements->data[i]); if (s) { s->toIR(p); } @@ -191,7 +191,7 @@ void ExpStatement::toIR(IRState* p) elem* e; // a cast(void) around the expression is allowed, but doesn't require any code if(exp->op == TOKcast && exp->type == Type::tvoid) { - CastExp* cexp = (CastExp*)exp; + CastExp* cexp = static_cast(exp); e = cexp->e1->toElemDtor(p); } else @@ -745,7 +745,7 @@ void TryCatchStatement::toIR(IRState* p) IRLandingPad& pad = gIR->func()->gen->landingPadInfo; for (unsigned i = 0; i < catches->dim; i++) { - Catch *c = (Catch *)catches->data[i]; + Catch *c = static_cast(catches->data[i]); pad.addCatch(c, endbb); } @@ -812,7 +812,7 @@ struct Case : Object } int compare(Object *obj) { - Case* c2 = (Case*)obj; + Case* c2 = static_cast(obj); return str->compare(c2->str); } }; @@ -868,7 +868,7 @@ void SwitchStatement::toIR(IRState* p) // clear data from previous passes... :/ for (unsigned i=0; idim; ++i) { - CaseStatement* cs = (CaseStatement*)cases->data[i]; + CaseStatement* cs = static_cast(cases->data[i]); cs->bodyBB = NULL; cs->llvmIdx = NULL; } @@ -879,10 +879,10 @@ void SwitchStatement::toIR(IRState* p) bool useSwitchInst = true; for (unsigned i=0; idim; ++i) { - CaseStatement* cs = (CaseStatement*)cases->data[i]; + CaseStatement* cs = static_cast(cases->data[i]); VarDeclaration* vd = 0; if (cs->exp->op == TOKvar) - vd = ((VarExp*)cs->exp)->var->isVarDeclaration(); + vd = static_cast(cs->exp)->var->isVarDeclaration(); if (vd && (!vd->init || !vd->isConst())) { cs->llvmIdx = cs->exp->toElemDtor(p)->getRVal(); useSwitchInst = false; @@ -926,10 +926,10 @@ void SwitchStatement::toIR(IRState* p) caseArray.reserve(cases->dim); for (unsigned i=0; idim; ++i) { - CaseStatement* cs = (CaseStatement*)cases->data[i]; + CaseStatement* cs = static_cast(cases->data[i]); assert(cs->exp->op == TOKstring); - caseArray.push(new Case((StringExp*)cs->exp, i)); + caseArray.push(new Case(static_cast(cs->exp), i)); } // first sort it caseArray.sort(); @@ -937,8 +937,8 @@ void SwitchStatement::toIR(IRState* p) std::vector inits(caseArray.dim); for (size_t i=0; idata[c->index]; + Case* c = static_cast(caseArray.data[i]); + CaseStatement* cs = static_cast(cases->data[c->index]); cs->llvmIdx = DtoConstUint(i); inits[i] = c->str->toConstElem(p); } @@ -978,7 +978,7 @@ void SwitchStatement::toIR(IRState* p) llvm::SwitchInst* si = llvm::SwitchInst::Create(condVal, defbb ? defbb : endbb, cases->dim, p->scopebb()); for (unsigned i=0; idim; ++i) { - CaseStatement* cs = (CaseStatement*)cases->data[i]; + CaseStatement* cs = static_cast(cases->data[i]); si->addCase(isaConstantInt(cs->llvmIdx), cs->bodyBB); } } @@ -993,7 +993,7 @@ void SwitchStatement::toIR(IRState* p) p->scope() = IRScope(nextbb, endbb); for (unsigned i=0; idim; ++i) { - CaseStatement* cs = (CaseStatement*)cases->data[i]; + CaseStatement* cs = static_cast(cases->data[i]); LLValue* cmp = p->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ, cs->llvmIdx, condVal, "checkcase"); nextbb = llvm::BasicBlock::Create(gIR->context(), "checkcase", p->topfunc(), oldend); @@ -1157,7 +1157,7 @@ void ForeachStatement::toIR(IRState* p) assert(aggr != 0); assert(func != 0); - //Argument* arg = (Argument*)arguments->data[0]; + //Argument* arg = static_cast(arguments->data[0]); //Logger::println("Argument is %s", arg->toChars()); Logger::println("aggr = %s", aggr->toChars()); @@ -1698,7 +1698,7 @@ AsmBlockStatement* CompoundStatement::endsWithAsm() if (statements && statements->dim) { unsigned last = statements->dim - 1; - Statement* s = (Statement*)statements->data[last]; + Statement* s = static_cast(statements->data[last]); if (s) return s->endsWithAsm(); } return NULL; diff --git a/gen/structs.cpp b/gen/structs.cpp index 661e4d0e..59c8d4b1 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -355,13 +355,13 @@ LLType* DtoUnpaddedStructType(Type* dty) { if (it != cache->end()) return it->second; - TypeStruct* sty = (TypeStruct*) dty; + TypeStruct* sty = static_cast(dty); Array& fields = sty->sym->fields; std::vector types; for (unsigned i = 0; i < fields.dim; i++) { - VarDeclaration* vd = (VarDeclaration*) fields.data[i]; + VarDeclaration* vd = static_cast(fields.data[i]); LLType* fty; if (vd->type->ty == Tstruct) { // Nested structs are the only members that can contain padding @@ -382,13 +382,13 @@ LLType* DtoUnpaddedStructType(Type* dty) { /// first-class struct value. LLValue* DtoUnpaddedStruct(Type* dty, LLValue* v) { assert(dty->ty == Tstruct); - TypeStruct* sty = (TypeStruct*) dty; + TypeStruct* sty = static_cast(dty); Array& fields = sty->sym->fields; LLValue* newval = llvm::UndefValue::get(DtoUnpaddedStructType(dty)); for (unsigned i = 0; i < fields.dim; i++) { - VarDeclaration* vd = (VarDeclaration*) fields.data[i]; + VarDeclaration* vd = static_cast(fields.data[i]); LLValue* fieldptr = DtoIndexStruct(v, sty->sym, vd); LLValue* fieldval; if (vd->type->ty == Tstruct) { @@ -405,11 +405,11 @@ LLValue* DtoUnpaddedStruct(Type* dty, LLValue* v) { /// Undo the transformation performed by DtoUnpaddedStruct, writing to lval. void DtoPaddedStruct(Type* dty, LLValue* v, LLValue* lval) { assert(dty->ty == Tstruct); - TypeStruct* sty = (TypeStruct*) dty; + TypeStruct* sty = static_cast(dty); Array& fields = sty->sym->fields; for (unsigned i = 0; i < fields.dim; i++) { - VarDeclaration* vd = (VarDeclaration*) fields.data[i]; + VarDeclaration* vd = static_cast(fields.data[i]); LLValue* fieldptr = DtoIndexStruct(lval, sty->sym, vd); LLValue* fieldval = DtoExtractValue(v, i); if (vd->type->ty == Tstruct) { diff --git a/gen/tocall.cpp b/gen/tocall.cpp index e2bfe6b4..0a83c0ec 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -21,13 +21,13 @@ TypeFunction* DtoTypeFunction(DValue* fnval) Type* type = fnval->getType()->toBasetype(); if (type->ty == Tfunction) { - return (TypeFunction*)type; + return static_cast(type); } else if (type->ty == Tdelegate) { Type* next = type->nextOf(); assert(next->ty == Tfunction); - return (TypeFunction*)next; + return static_cast(next); } assert(0 && "cant get TypeFunction* from non lazy/function/delegate"); @@ -200,7 +200,7 @@ void DtoBuildDVarArgList(std::vector& args, // build struct with argument types (non variadic args) for (int i=begin; idata[i]; + Expression* argexp = static_cast(arguments->data[i]); assert(argexp->type->ty != Ttuple); vtypes.push_back(DtoType(argexp->type)); size_t sz = getTypePaddedSize(vtypes.back()); @@ -237,7 +237,7 @@ void DtoBuildDVarArgList(std::vector& args, // store arguments in the struct for (int i=begin,k=0; idata[i]; + Expression* argexp = static_cast(arguments->data[i]); if (global.params.llvmAnnotate) DtoAnnotation(argexp->toChars()); LLValue* argdst = DtoGEPi(mem,0,k); @@ -257,7 +257,7 @@ void DtoBuildDVarArgList(std::vector& args, std::vector vtypeinfos; for (int i=begin,k=0; idata[i]; + Expression* argexp = static_cast(arguments->data[i]); vtypeinfos.push_back(DtoTypeInfoOf(argexp->type)); } @@ -295,7 +295,7 @@ void DtoBuildDVarArgList(std::vector& args, for (int i=0; iparameters, i); - DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); + DValue* argval = DtoArgument(fnarg, static_cast(arguments->data[i])); args.push_back(fixArgument(argval, tf, callableTy->getParamType(argidx++), i)); if (tf->fty.args[i]->attrs) @@ -465,7 +465,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* { for (int i=0; idata[i]; + Expression* exp = static_cast(arguments->data[i]); DValue* expelem = exp->toElem(gIR); // cast to va_list* LLValue* val = DtoBitCast(expelem->getLVal(), getVoidPtrType()); @@ -486,7 +486,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* { Logger::println("doing normal arguments"); if (Logger::enabled()) { - Logger::println("Arguments so far: (%d)", (int)args.size()); + Logger::println("Arguments so far: (%d)", static_cast(args.size())); Logger::indent(); for (size_t i = 0; i < args.size(); i++) { Logger::cout() << *args[i] << '\n'; @@ -504,14 +504,14 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* for (int i=n-1; i>=0; --i) { Parameter* fnarg = Parameter::getNth(tf->parameters, i); assert(fnarg); - DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); + DValue* argval = DtoArgument(fnarg, static_cast(arguments->data[i])); argvals.insert(argvals.begin(), argval); } } else { for (int i=0; iparameters, i); assert(fnarg); - DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); + DValue* argval = DtoArgument(fnarg, static_cast(arguments->data[i])); argvals.push_back(argval); } } @@ -554,7 +554,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* for (int i=n; iparameters, i); - DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); + DValue* argval = DtoArgument(fnarg, static_cast(arguments->data[i])); LLValue* arg = argval->getRVal(); // FIXME: do we need any param attrs here ? @@ -669,7 +669,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* { LLFunction* llfunc = llvm::dyn_cast(dfnval->val); if (llfunc && llfunc->isIntrinsic()) // override intrinsic attrs - attrlist = llvm::Intrinsic::getAttributes((llvm::Intrinsic::ID)llfunc->getIntrinsicID()); + attrlist = llvm::Intrinsic::getAttributes(static_cast(llfunc->getIntrinsicID())); else call.setCallingConv(callconv); } diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 4dabc9aa..fb981f33 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -46,7 +46,7 @@ static llvm::DIDescriptor getCurrentScope() { IrFunction *fn = gIR->func(); if (fn->diLexicalBlocks.empty()) { - assert((llvm::MDNode*)fn->diSubprogram != 0); + assert(static_cast(fn->diSubprogram) != 0); return fn->diSubprogram; } return fn->diLexicalBlocks.top(); @@ -197,12 +197,12 @@ static llvm::DIType dwarfCompositeType(Type* type) AggregateDeclaration* sd; if (t->ty == Tstruct) { - TypeStruct* ts = (TypeStruct*)t; + TypeStruct* ts = static_cast(t); sd = ts->sym; } else { - TypeClass* tc = (TypeClass*)t; + TypeClass* tc = static_cast(t); sd = tc->sym; } assert(sd); @@ -217,7 +217,7 @@ static llvm::DIType dwarfCompositeType(Type* type) IrStruct* ir = sd->ir.irStruct; assert(ir); - if ((llvm::MDNode*)ir->diCompositeType != 0) + if (static_cast(ir->diCompositeType) != 0) return ir->diCompositeType; name = sd->toChars(); @@ -384,7 +384,7 @@ void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd, llvm::ArrayReftype, NULL); - if ((llvm::MDNode*)TD == 0) + if (static_cast(TD) == 0) return; // unsupported // get variable description @@ -468,7 +468,7 @@ llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd) LOG_SCOPE; llvm::DIFile file = DtoDwarfFile(fd->loc); - Type *retType = ((TypeFunction*)fd->type)->next; + Type *retType = static_cast(fd->type)->next; // FIXME: duplicates ? return gIR->dibuilder.createFunction( @@ -541,7 +541,7 @@ void DtoDwarfFuncStart(FuncDeclaration* fd) Logger::println("D to dwarf funcstart"); LOG_SCOPE; - assert((llvm::MDNode*)fd->ir.irFunc->diSubprogram != 0); + assert(static_cast(fd->ir.irFunc->diSubprogram) != 0); DtoDwarfStopPoint(fd->loc.linnum); } @@ -555,7 +555,7 @@ void DtoDwarfFuncEnd(FuncDeclaration* fd) Logger::println("D to dwarf funcend"); LOG_SCOPE; - assert((llvm::MDNode*)fd->ir.irFunc->diSubprogram != 0); + assert(static_cast(fd->ir.irFunc->diSubprogram) != 0); } ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/toir.cpp b/gen/toir.cpp index 43d60008..460da636 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -258,7 +258,7 @@ DValue* VarExp::toElem(IRState* p) Type* sdecltype = sdecl->type->toBasetype(); Logger::print("Sym: type=%s\n", sdecltype->toChars()); assert(sdecltype->ty == Tstruct); - TypeStruct* ts = (TypeStruct*)sdecltype; + TypeStruct* ts = static_cast(sdecltype); assert(ts->sym); ts->sym->codegen(Type::sir); @@ -287,7 +287,7 @@ LLConstant* VarExp::toConstElem(IRState* p) Type* sdecltype = sdecl->type->toBasetype(); Logger::print("Sym: type=%s\n", sdecltype->toChars()); assert(sdecltype->ty == Tstruct); - TypeStruct* ts = (TypeStruct*)sdecltype; + TypeStruct* ts = static_cast(sdecltype); ts->sym->codegen(Type::sir); return ts->sym->ir.irStruct->getDefaultInit(); @@ -471,12 +471,12 @@ DValue* StringExp::toElem(IRState* p) LLConstant* _init; #if LDC_LLVM_VER == 300 if (cty->size() == 1) { - uint8_t* str = (uint8_t*)string; + uint8_t* str = static_cast(string); llvm::StringRef cont((char*)str, len); _init = LLConstantArray::get(p->context(), cont, true); } else if (cty->size() == 2) { - uint16_t* str = (uint16_t*)string; + uint16_t* str = static_cast(string); std::vector vals; vals.reserve(len+1); for(size_t i=0; isize() == 4) { - uint32_t* str = (uint32_t*)string; + uint32_t* str = static_cast(string); std::vector vals; vals.reserve(len+1); for(size_t i=0; isize() == 1) { - uint8_t* str = (uint8_t*)string; + uint8_t* str = static_cast(string); llvm::StringRef cont((char*)str, len); _init = LLConstantArray::get(p->context(), cont, nullterm); } else if (cty->size() == 2) { - uint16_t* str = (uint16_t*)string; + uint16_t* str = static_cast(string); std::vector vals; vals.reserve(len+1); for(size_t i=0; isize() == 4) { - uint32_t* str = (uint32_t*)string; + uint32_t* str = static_cast(string); std::vector vals; vals.reserve(len+1); for(size_t i=0; iop == TOKarraylength) { Logger::println("performing array.length assignment"); - ArrayLengthExp *ale = (ArrayLengthExp *)e1; + ArrayLengthExp *ale = static_cast(e1); DValue* arr = ale->e1->toElem(p); DVarValue arrval(ale->e1->type, arr->getLVal()); DValue* newlen = e2->toElem(p); @@ -669,7 +669,7 @@ static Expression* findLvalue(IRState* irs, Expression* exp) // skip past any casts while(e->op == TOKcast) - e = ((CastExp*)e)->e1; + e = static_cast(e)->e1; // cache lvalue and return e->cacheLvalue(irs); @@ -688,7 +688,7 @@ DValue* X##AssignExp::toElem(IRState* p) \ /* Now that we are done with the expression, clear the cached lvalue. */ \ Expression* e = e1; \ while(e->op == TOKcast) \ - e = ((CastExp*)e)->e1; \ + e = static_cast(e)->e1; \ e->cachedLvalue = NULL; \ /* Assign the (casted) value and return it. */ \ DValue* stval = DtoCast(loc, res, dst->getType()); \ @@ -919,7 +919,7 @@ DValue* CallExp::toElem(IRState* p) // handle magic inline asm if (e1->op == TOKvar) { - VarExp* ve = (VarExp*)e1; + VarExp* ve = static_cast(e1); if (FuncDeclaration* fd = ve->var->isFuncDeclaration()) { if (fd->llvmInternal == LLVMinline_asm) @@ -945,7 +945,7 @@ DValue* CallExp::toElem(IRState* p) { if (fndecl->linkage == LINKc && strcmp(fndecl->ident->string, "printf") == 0) { - warnInvalidPrintfCall(loc, (Expression*)arguments->data[0], arguments->dim); + warnInvalidPrintfCall(loc, static_cast(arguments->data[0]), arguments->dim); } } @@ -956,7 +956,7 @@ DValue* CallExp::toElem(IRState* p) return NULL; } // llvm doesn't need the second param hence the override - Expression* exp = (Expression*)arguments->data[0]; + Expression* exp = static_cast(arguments->data[0]); LLValue* arg = exp->toElem(p)->getLVal(); #if DMDV2 if (LLValue *argptr = gIR->func()->_argptr) { @@ -980,8 +980,8 @@ DValue* CallExp::toElem(IRState* p) error("va_copy instruction expects 2 arguments"); return NULL; } - Expression* exp1 = (Expression*)arguments->data[0]; - Expression* exp2 = (Expression*)arguments->data[1]; + Expression* exp1 = static_cast(arguments->data[0]); + Expression* exp2 = static_cast(arguments->data[1]); LLValue* arg1 = exp1->toElem(p)->getLVal(); LLValue* arg2 = exp2->toElem(p)->getLVal(); @@ -998,7 +998,7 @@ DValue* CallExp::toElem(IRState* p) error("va_arg instruction expects 1 arguments"); return NULL; } - return DtoVaArg(loc, type, (Expression*)arguments->data[0]); + return DtoVaArg(loc, type, static_cast(arguments->data[0])); } // C alloca else if (fndecl->llvmInternal == LLVMalloca) { @@ -1006,7 +1006,7 @@ DValue* CallExp::toElem(IRState* p) error("alloca expects 1 arguments"); return NULL; } - Expression* exp = (Expression*)arguments->data[0]; + Expression* exp = static_cast(arguments->data[0]); DValue* expv = exp->toElem(p); if (expv->getType()->toBasetype()->ty != Tint32) expv = DtoCast(loc, expv, Type::tint32); @@ -1017,7 +1017,7 @@ DValue* CallExp::toElem(IRState* p) error("fence instruction expects 1 arguments"); return NULL; } - gIR->ir->CreateFence(llvm::AtomicOrdering(((Expression*)arguments->data[0])->toInteger())); + gIR->ir->CreateFence(llvm::AtomicOrdering(static_cast(arguments->data[0])->toInteger())); return NULL; // atomic store instruction } else if (fndecl->llvmInternal == LLVMatomic_store) { @@ -1025,9 +1025,9 @@ DValue* CallExp::toElem(IRState* p) error("atomic store instruction expects 3 arguments"); return NULL; } - Expression* exp1 = (Expression*)arguments->data[0]; - Expression* exp2 = (Expression*)arguments->data[1]; - int atomicOrdering = ((Expression*)arguments->data[2])->toInteger(); + Expression* exp1 = static_cast(arguments->data[0]); + Expression* exp2 = static_cast(arguments->data[1]); + int atomicOrdering = static_cast(arguments->data[2])->toInteger(); LLValue* val = exp1->toElem(p)->getRVal(); LLValue* ptr = exp2->toElem(p)->getRVal(); llvm::StoreInst* ret = gIR->ir->CreateStore(val, ptr, "tmp"); @@ -1040,8 +1040,8 @@ DValue* CallExp::toElem(IRState* p) error("atomic load instruction expects 2 arguments"); return NULL; } - Expression* exp = (Expression*)arguments->data[0]; - int atomicOrdering = ((Expression*)arguments->data[1])->toInteger(); + Expression* exp = static_cast(arguments->data[0]); + int atomicOrdering = static_cast(arguments->data[1])->toInteger(); LLValue* ptr = exp->toElem(p)->getRVal(); Type* retType = exp->type->nextOf(); llvm::LoadInst* val = gIR->ir->CreateLoad(ptr, "tmp"); @@ -1054,10 +1054,10 @@ DValue* CallExp::toElem(IRState* p) error("cmpxchg instruction expects 4 arguments"); return NULL; } - Expression* exp1 = (Expression*)arguments->data[0]; - Expression* exp2 = (Expression*)arguments->data[1]; - Expression* exp3 = (Expression*)arguments->data[2]; - int atomicOrdering = ((Expression*)arguments->data[3])->toInteger(); + Expression* exp1 = static_cast(arguments->data[0]); + Expression* exp2 = static_cast(arguments->data[1]); + Expression* exp3 = static_cast(arguments->data[2]); + int atomicOrdering = static_cast(arguments->data[3])->toInteger(); LLValue* ptr = exp1->toElem(p)->getRVal(); LLValue* cmp = exp2->toElem(p)->getRVal(); LLValue* val = exp3->toElem(p)->getRVal(); @@ -1095,9 +1095,9 @@ DValue* CallExp::toElem(IRState* p) break; } - Expression* exp1 = (Expression*)arguments->data[0]; - Expression* exp2 = (Expression*)arguments->data[1]; - int atomicOrdering = ((Expression*)arguments->data[2])->toInteger(); + Expression* exp1 = static_cast(arguments->data[0]); + Expression* exp2 = static_cast(arguments->data[1]); + int atomicOrdering = static_cast(arguments->data[2])->toInteger(); LLValue* ptr = exp1->toElem(p)->getRVal(); LLValue* val = exp2->toElem(p)->getRVal(); LLValue* ret = gIR->ir->CreateAtomicRMW(llvm::AtomicRMWInst::BinOp(op), ptr, val, @@ -1114,8 +1114,8 @@ DValue* CallExp::toElem(IRState* p) return NULL; } - Expression* exp1 = (Expression*)arguments->data[0]; - Expression* exp2 = (Expression*)arguments->data[1]; + Expression* exp1 = static_cast(arguments->data[0]); + Expression* exp2 = static_cast(arguments->data[1]); LLValue* ptr = exp1->toElem(p)->getRVal(); LLValue* bitnum = exp2->toElem(p)->getRVal(); @@ -1197,7 +1197,7 @@ LLConstant* CastExp::toConstElem(IRState* p) // string literal to dyn array: // reinterpret the string data as an array, calculate the length if (e1->op == TOKstring && tb->ty == Tarray) { -/* StringExp *strexp = (StringExp*)e1; +/* StringExp *strexp = static_cast(e1); size_t datalen = strexp->sz * strexp->len; Type* eltype = tb->nextOf()->toBasetype(); if (datalen % eltype->size() != 0) { @@ -1214,7 +1214,7 @@ LLConstant* CastExp::toConstElem(IRState* p) } // global variable to pointer else if (tb->ty == Tpointer && e1->op == TOKvar) { - VarDeclaration *vd = ((VarExp*)e1)->var->isVarDeclaration(); + VarDeclaration *vd = static_cast(e1)->var->isVarDeclaration(); assert(vd); vd->codegen(Type::sir); LLConstant *value = vd->ir.irGlobal ? isaConstant(vd->ir.irGlobal->value) : 0; @@ -1302,7 +1302,7 @@ LLConstant* AddrExp::toConstElem(IRState* p) // address of global variable if (e1->op == TOKvar) { - VarExp* vexp = (VarExp*)e1; + VarExp* vexp = static_cast(e1); // make sure 'this' isn't needed if (vexp->var->needThis()) @@ -1336,11 +1336,11 @@ LLConstant* AddrExp::toConstElem(IRState* p) // address of indexExp else if (e1->op == TOKindex) { - IndexExp* iexp = (IndexExp*)e1; + IndexExp* iexp = static_cast(e1); // indexee must be global static array var assert(iexp->e1->op == TOKvar); - VarExp* vexp = (VarExp*)iexp->e1; + VarExp* vexp = static_cast(iexp->e1); VarDeclaration* vd = vexp->var->isVarDeclaration(); assert(vd); assert(vd->type->toBasetype()->ty == Tsarray); @@ -1446,17 +1446,17 @@ DValue* DotVarExp::toElem(IRState* p) // indexing struct pointer if (e1type->ty == Tpointer) { assert(e1type->nextOf()->ty == Tstruct); - TypeStruct* ts = (TypeStruct*)e1type->nextOf(); + TypeStruct* ts = static_cast(e1type->nextOf()); arrptr = DtoIndexStruct(l->getRVal(), ts->sym, vd); } // indexing normal struct else if (e1type->ty == Tstruct) { - TypeStruct* ts = (TypeStruct*)e1type; + TypeStruct* ts = static_cast(e1type); arrptr = DtoIndexStruct(l->getRVal(), ts->sym, vd); } // indexing class else if (e1type->ty == Tclass) { - TypeClass* tc = (TypeClass*)e1type; + TypeClass* tc = static_cast(e1type); arrptr = DtoIndexClass(l->getRVal(), tc->sym, vd); } else @@ -1472,7 +1472,7 @@ DValue* DotVarExp::toElem(IRState* p) LLValue* funcval; LLValue* vthis2 = 0; if (e1type->ty == Tclass) { - TypeClass* tc = (TypeClass*)e1type; + TypeClass* tc = static_cast(e1type); if (tc->sym->isInterfaceDeclaration() && !fdecl->isFinal()) vthis2 = DtoCastInterfaceToObject(l, NULL)->getRVal(); } @@ -1491,7 +1491,7 @@ DValue* DotVarExp::toElem(IRState* p) if (e->op == TOKsuper || e->op == TOKdottype) vtbllookup = false; else if (e->op == TOKcast) - e = ((CastExp*)e)->e1; + e = static_cast(e)->e1; else break; } @@ -1675,7 +1675,7 @@ DValue* SliceExp::toElem(IRState* p) // (namely default initialization, int[16][16] arr; -> int[256] arr = 0;) if (etype->ty == Tsarray) { - TypeSArray* tsa = (TypeSArray*)etype; + TypeSArray* tsa = static_cast(etype); elen = DtoConstSize_t(tsa->dim->toUInteger()); // in this case, we also need to make sure the pointer is cast to the innermost element type @@ -1919,8 +1919,8 @@ DValue* PostExp::toElem(IRState* p) else if (e1type->ty == Tpointer) { assert(e2->op == TOKint64); - LLConstant* minusone = LLConstantInt::get(DtoSize_t(),(uint64_t)-1,true); - LLConstant* plusone = LLConstantInt::get(DtoSize_t(),(uint64_t)1,false); + LLConstant* minusone = LLConstantInt::get(DtoSize_t(),static_cast(-1),true); + LLConstant* plusone = LLConstantInt::get(DtoSize_t(),static_cast(1),false); LLConstant* whichone = (op == TOKplusplus) ? plusone : minusone; post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb()); } @@ -1956,7 +1956,7 @@ DValue* NewExp::toElem(IRState* p) // new class if (ntype->ty == Tclass) { Logger::println("new class"); - return DtoNewClass(loc, (TypeClass*)ntype, this); + return DtoNewClass(loc, static_cast(ntype), this); } // new dynamic array else if (ntype->ty == Tarray) @@ -1967,7 +1967,7 @@ DValue* NewExp::toElem(IRState* p) assert(arguments->dim >= 1); if (arguments->dim == 1) { - DValue* sz = ((Expression*)arguments->data[0])->toElem(p); + DValue* sz = static_cast(arguments->data[0])->toElem(p); // allocate & init return DtoNewDynArray(loc, newtype, sz, true); } @@ -1976,7 +1976,7 @@ DValue* NewExp::toElem(IRState* p) size_t ndims = arguments->dim; std::vector dims(ndims); for (size_t i=0; idata[i])->toElem(p); + dims[i] = static_cast(arguments->data[i])->toElem(p); return DtoNewMulDimDynArray(loc, newtype, &dims[0], ndims, true); } } @@ -2006,7 +2006,7 @@ DValue* NewExp::toElem(IRState* p) mem = DtoNew(newtype); } // init - TypeStruct* ts = (TypeStruct*)ntype; + TypeStruct* ts = static_cast(ntype); if (ts->isZeroInit(ts->sym->loc)) { DtoAggrZeroInit(mem); } @@ -2077,7 +2077,7 @@ DValue* DeleteExp::toElem(IRState* p) else if (et->ty == Tclass) { bool onstack = false; - TypeClass* tc = (TypeClass*)et; + TypeClass* tc = static_cast(et); if (tc->sym->isInterfaceDeclaration()) { #if DMDV2 @@ -2146,7 +2146,7 @@ DValue* AssertExp::toElem(IRState* p) Type* condty; // special case for dmd generated assert(this); when not in -release mode - if (e1->op == TOKthis && ((ThisExp*)e1)->var == NULL) + if (e1->op == TOKthis && static_cast(e1)->var == NULL) { LLValue* thisarg = p->func()->thisArg; assert(thisarg && "null thisarg, but we're in assert(this) exp;"); @@ -2184,7 +2184,7 @@ DValue* AssertExp::toElem(IRState* p) if( global.params.useInvariants && condty->ty == Tclass && - !((TypeClass*)condty)->sym->isInterfaceDeclaration()) + !(static_cast(condty)->sym->isInterfaceDeclaration())) { Logger::println("calling class invariant"); llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_invariant"); @@ -2195,10 +2195,10 @@ DValue* AssertExp::toElem(IRState* p) else if( global.params.useInvariants && condty->ty == Tpointer && condty->nextOf()->ty == Tstruct && - (invdecl = ((TypeStruct*)condty->nextOf())->sym->inv) != NULL) + (invdecl = static_cast(condty->nextOf())->sym->inv) != NULL) { Logger::print("calling struct invariant"); - ((TypeStruct*)condty->nextOf())->sym->codegen(Type::sir); + static_cast(condty->nextOf())->sym->codegen(Type::sir); DFuncValue invfunc(invdecl, invdecl->ir.irFunc->func, cond->getRVal()); DtoCallFunction(loc, NULL, &invfunc, NULL); } @@ -2580,7 +2580,7 @@ DValue* ComExp::toElem(IRState* p) DValue* u = e1->toElem(p); LLValue* value = u->getRVal(); - LLValue* minusone = LLConstantInt::get(value->getType(), (uint64_t)-1, true); + LLValue* minusone = LLConstantInt::get(value->getType(), static_cast(-1), true); value = llvm::BinaryOperator::Create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb()); return new DImValue(type, value); @@ -2798,7 +2798,7 @@ DValue* ArrayLiteralExp::toElem(IRState* p) // store elements for (size_t i=0; idata[i]; + Expression* expr = static_cast(elements->data[i]); LLValue* elemAddr; if(dyn) elemAddr = DtoGEPi1(dstMem, i, "tmp", p->scopebb()); @@ -2840,7 +2840,7 @@ LLConstant* ArrayLiteralExp::toConstElem(IRState* p) std::vector vals(elements->dim, NULL); for (unsigned i=0; idim; ++i) { - Expression* expr = (Expression*)elements->data[i]; + Expression* expr = static_cast(elements->data[i]); vals[i] = expr->toConstElem(p); } @@ -2958,7 +2958,7 @@ DValue* StructLiteralExp::toElem(IRState* p) if (tb->ty == Tstruct) { // Call postBlit() - StructDeclaration *sd = ((TypeStruct *)tb)->sym; + StructDeclaration *sd = static_cast(tb)->sym; if (sd->postblit) { FuncDeclaration *fd = sd->postblit; @@ -3087,7 +3087,7 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) } assert(aatype->ty == Taarray); - Type* indexType = ((TypeAArray*)aatype)->index; + Type* indexType = static_cast(aatype)->index; assert(indexType && vtype); llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_assocarrayliteralTX"); @@ -3131,8 +3131,8 @@ LruntimeInit: const size_t n = keys->dim; for (size_t i=0; idata[i]; - Expression* eval = (Expression*)values->data[i]; + Expression* ekey = static_cast(keys->data[i]); + Expression* eval = static_cast(values->data[i]); Logger::println("(%zu) aa[%s] = %s", i, ekey->toChars(), eval->toChars()); @@ -3194,13 +3194,13 @@ DValue* TupleExp::toElem(IRState *p) std::vector types(exps->dim, NULL); for (size_t i = 0; i < exps->dim; i++) { - Expression *el = (Expression *)exps->data[i]; + Expression *el = static_cast(exps->data[i]); types[i] = DtoTypeNotVoid(el->type); } LLValue *val = DtoRawAlloca(LLStructType::get(gIR->context(), types),0, "tuple"); for (size_t i = 0; i < exps->dim; i++) { - Expression *el = (Expression *)exps->data[i]; + Expression *el = static_cast(exps->data[i]); DValue* ep = el->toElem(p); LLValue *gep = DtoGEPi(val,0,i); if (el->type->ty == Tstruct) @@ -3221,7 +3221,7 @@ DValue* VectorExp::toElem(IRState* p) { Logger::print("VectorExp::toElem() %s\n", toChars()); - TypeVector *type = (TypeVector*)to->toBasetype(); + TypeVector *type = static_cast(to->toBasetype()); assert(type->ty == Tvector); DValue *val = e1->toElem(p); @@ -3269,7 +3269,7 @@ CONSTSTUB(AssocArrayLiteralExp); void obj_includelib(const char* lib) { size_t n = strlen(lib)+3; - char *arg = (char *)mem.malloc(n); + char *arg = static_cast(mem.malloc(n)); strcpy(arg, "-l"); strncat(arg, lib, n); global.params.linkswitches->push(arg); diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 5fa3d24d..66d05fb7 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -119,12 +119,12 @@ LLType* DtoType(Type* t) // aggregates case Tstruct: { - TypeStruct* ts = (TypeStruct*)t; + TypeStruct* ts = static_cast(t); t->irtype = new IrTypeStruct(ts->sym); return t->irtype->buildType(); } case Tclass: { - TypeClass* tc = (TypeClass*)t; + TypeClass* tc = static_cast(t); t->irtype = new IrTypeClass(tc->sym); return t->irtype->buildType(); } @@ -173,7 +173,7 @@ LLType* DtoType(Type* t) case Ttuple: { - TypeTuple* ttupl = (TypeTuple*)t; + TypeTuple* ttupl = static_cast(t); return DtoStructTypeFromArguments(ttupl->arguments); } */ @@ -196,7 +196,7 @@ LLType* DtoStructTypeFromArguments(Arguments* arguments) std::vector types; for (size_t i = 0; i < arguments->dim; i++) { - Argument *arg = (Argument *)arguments->data[i]; + Argument *arg = static_cast(arguments->data[i]); assert(arg && arg->type); types.push_back(DtoType(arg->type)); @@ -267,7 +267,7 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym) if (mustDefineSymbol(fdecl)) Logger::println("Function %savailable externally: %s", (fdecl->availableExternally ? "" : "not "), fdecl->toChars()); assert(fdecl->type->ty == Tfunction); - TypeFunction* ft = (TypeFunction*)fdecl->type; + TypeFunction* ft = static_cast(fdecl->type); // intrinsics are always external if (fdecl->llvmInternal == LLVMintrinsic) @@ -595,8 +595,8 @@ LLConstant* DtoConstFP(Type* t, longdouble value) return LLConstantFP::get(llty, value); else if(llty == LLType::getX86_FP80Ty(gIR->context())) { uint64_t bits[] = {0, 0}; - bits[0] = *(uint64_t*)&value; - bits[1] = *(uint16_t*)((uint64_t*)&value + 1); + bits[0] = *reinterpret_cast(&value); + bits[1] = *reinterpret_cast(reinterpret_cast(&value + 1)); return LLConstantFP::get(gIR->context(), APFloat(APInt(80, 2, bits))); } else { assert(0 && "Unknown floating point type encountered"); diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 3f97e659..2dca8aa6 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -72,7 +72,7 @@ Expression *Type::getInternalTypeInfo(Scope *sc) break; case Tclass: - if (((TypeClass *)t)->sym->isInterfaceDeclaration()) + if (static_cast(t)->sym->isInterfaceDeclaration()) break; goto Linternal; @@ -403,7 +403,7 @@ void TypeInfoTypedefDeclaration::llvmDefine() RTTIBuilder b(Type::typeinfotypedef); assert(tinfo->ty == Ttypedef); - TypeTypedef *tc = (TypeTypedef *)tinfo; + TypeTypedef *tc = static_cast(tinfo); TypedefDeclaration *sd = tc->sym; // TypeInfo base @@ -441,7 +441,7 @@ void TypeInfoEnumDeclaration::llvmDefine() RTTIBuilder b(Type::typeinfoenum); assert(tinfo->ty == Tenum); - TypeEnum *tc = (TypeEnum *)tinfo; + TypeEnum *tc = static_cast(tinfo); EnumDeclaration *sd = tc->sym; // TypeInfo base @@ -509,7 +509,7 @@ void TypeInfoStaticArrayDeclaration::llvmDefine() LOG_SCOPE; assert(tinfo->ty == Tsarray); - TypeSArray *tc = (TypeSArray *)tinfo; + TypeSArray *tc = static_cast(tinfo); RTTIBuilder b(Type::typeinfostaticarray); @@ -517,7 +517,7 @@ void TypeInfoStaticArrayDeclaration::llvmDefine() b.push_typeinfo(tc->nextOf()); // length - b.push(DtoConstSize_t((size_t)tc->dim->toUInteger())); + b.push(DtoConstSize_t(static_cast(tc->dim->toUInteger()))); // finish b.finalize(ir.irGlobal); @@ -531,7 +531,7 @@ void TypeInfoAssociativeArrayDeclaration::llvmDefine() LOG_SCOPE; assert(tinfo->ty == Taarray); - TypeAArray *tc = (TypeAArray *)tinfo; + TypeAArray *tc = static_cast(tinfo); RTTIBuilder b(Type::typeinfoassociativearray); @@ -609,7 +609,7 @@ void TypeInfoStructDeclaration::llvmDefine() // make sure struct is resolved assert(tinfo->ty == Tstruct); - TypeStruct *tc = (TypeStruct *)tinfo; + TypeStruct *tc = static_cast(tinfo); StructDeclaration *sd = tc->sym; // can't emit typeinfo for forward declarations @@ -644,7 +644,7 @@ void TypeInfoStructDeclaration::llvmDefine() #if DMDV2 tftohash ->mod = MODconst; #endif - tftohash = (TypeFunction *)tftohash->semantic(0, &sc); + tftohash = static_cast(tftohash->semantic(0, &sc)); #if DMDV2 Type *retType = Type::tchar->invariantOf()->arrayOf(); @@ -652,7 +652,7 @@ void TypeInfoStructDeclaration::llvmDefine() Type *retType = Type::tchar->arrayOf(); #endif tftostring = new TypeFunction(NULL, retType, 0, LINKd); - tftostring = (TypeFunction *)tftostring->semantic(0, &sc); + tftostring = static_cast(tftostring->semantic(0, &sc)); } // this one takes a parameter, so we need to build a new one each time @@ -673,7 +673,7 @@ void TypeInfoStructDeclaration::llvmDefine() #if DMDV2 tfcmpptr->mod = MODconst; #endif - tfcmpptr = (TypeFunction *)tfcmpptr->semantic(0, &sc); + tfcmpptr = static_cast(tfcmpptr->semantic(0, &sc)); } // well use this module for all overload lookups @@ -733,7 +733,7 @@ void TypeInfoStructDeclaration::llvmDefine() { if (i < tup->arguments->dim) { - Type *targ = ((Parameter *)tup->arguments->data[i])->type; + Type *targ = static_cast(tup->arguments->data[i])->type; targ = targ->merge(); b.push_typeinfo(targ); } @@ -757,7 +757,7 @@ void TypeInfoClassDeclaration::codegen(Ir*i) IrGlobal* irg = new IrGlobal(this); ir.irGlobal = irg; assert(tinfo->ty == Tclass); - TypeClass *tc = (TypeClass *)tinfo; + TypeClass *tc = static_cast(tinfo); tc->sym->codegen(Type::sir); // make sure class is resolved irg->value = tc->sym->ir.irStruct->getClassInfoSymbol(); } @@ -773,7 +773,7 @@ void TypeInfoClassDeclaration::llvmDefine() // make sure class is resolved assert(tinfo->ty == Tclass); - TypeClass *tc = (TypeClass *)tinfo; + TypeClass *tc = static_cast(tinfo); tc->sym->codegen(Type::sir); RTTIBuilder b(Type::typeinfoclass); @@ -794,7 +794,7 @@ void TypeInfoInterfaceDeclaration::llvmDefine() // make sure interface is resolved assert(tinfo->ty == Tclass); - TypeClass *tc = (TypeClass *)tinfo; + TypeClass *tc = static_cast(tinfo); tc->sym->codegen(Type::sir); RTTIBuilder b(Type::typeinfointerface); @@ -815,7 +815,7 @@ void TypeInfoTupleDeclaration::llvmDefine() // create elements array assert(tinfo->ty == Ttuple); - TypeTuple *tu = (TypeTuple *)tinfo; + TypeTuple *tu = static_cast(tinfo); size_t dim = tu->arguments->dim; std::vector arrInits; @@ -825,7 +825,7 @@ void TypeInfoTupleDeclaration::llvmDefine() for (size_t i = 0; i < dim; i++) { - Parameter *arg = (Parameter *)tu->arguments->data[i]; + Parameter *arg = static_cast(tu->arguments->data[i]); arrInits.push_back(DtoTypeInfoOf(arg->type, true)); } @@ -910,7 +910,7 @@ void TypeInfoVectorDeclaration::llvmDefine() LOG_SCOPE; assert(tinfo->ty == Tvector); - TypeVector *tv = (TypeVector *)tinfo; + TypeVector *tv = static_cast(tinfo); RTTIBuilder b(Type::typeinfovector); // TypeInfo base diff --git a/gen/warnings.cpp b/gen/warnings.cpp index cbb33835..450e43d8 100644 --- a/gen/warnings.cpp +++ b/gen/warnings.cpp @@ -13,7 +13,7 @@ void warnInvalidPrintfCall(Loc loc, Expression* arguments, size_t nargs) if (arg->op != TOKstring) return; // assume valid - StringExp* strexp = (StringExp*)arg; + StringExp* strexp = static_cast(arg); // not wchar or dhar if (strexp->sz != 1) @@ -24,7 +24,7 @@ void warnInvalidPrintfCall(Loc loc, Expression* arguments, size_t nargs) #if 0 // check the format string - const char* str = (char*)strexp->string; + const char* str = static_cast(strexp->string); for (size_t i = 0; i < strexp->len; ++i) { // TODO