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-02 19:55:29 +02:00
parent 9dad0a6b3b
commit 2dbee75523
21 changed files with 227 additions and 227 deletions

View File

@@ -355,13 +355,13 @@ LLType* DtoUnpaddedStructType(Type* dty) {
if (it != cache->end())
return it->second;
TypeStruct* sty = (TypeStruct*) dty;
TypeStruct* sty = static_cast<TypeStruct*>(dty);
Array& fields = sty->sym->fields;
std::vector<LLType*> types;
for (unsigned i = 0; i < fields.dim; i++) {
VarDeclaration* vd = (VarDeclaration*) fields.data[i];
VarDeclaration* vd = static_cast<VarDeclaration*>(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<TypeStruct*>(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<VarDeclaration*>(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<TypeStruct*>(dty);
Array& fields = sty->sym->fields;
for (unsigned i = 0; i < fields.dim; i++) {
VarDeclaration* vd = (VarDeclaration*) fields.data[i];
VarDeclaration* vd = static_cast<VarDeclaration*>(fields.data[i]);
LLValue* fieldptr = DtoIndexStruct(lval, sty->sym, vd);
LLValue* fieldval = DtoExtractValue(v, i);
if (vd->type->ty == Tstruct) {