aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/d-codegen.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-06-03 15:26:25 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2020-06-16 23:31:24 +0200
commit89fdaf5ad853c3d55060b9929027946833aee77a (patch)
treebd31fe1405120ce155c606fb258d6944e6a6be6b /gcc/d/d-codegen.cc
parent8fb4d1d58362b77da78c09740c6b5562124a369e (diff)
downloadgcc-89fdaf5ad853c3d55060b9929027946833aee77a.zip
gcc-89fdaf5ad853c3d55060b9929027946833aee77a.tar.gz
gcc-89fdaf5ad853c3d55060b9929027946833aee77a.tar.bz2
d: Use new isTypeXxxx helpers where possible.
gcc/d/ChangeLog: * d-builtins.cc (d_eval_constant_expression): Use isTypeXxxx helpers instead of explicit casts. (d_build_builtins_module): Likewise. * d-codegen.cc (get_array_length): Likewise. (identity_compare_p): Likewise. (lower_struct_comparison): Likewise. (build_array_from_val): Likewise. (array_bounds_check): Likewise. (get_function_type): Likewise. (d_build_call): Likewise. * d-compiler.cc (Compiler::paintAsType): Likewise. * d-convert.cc (convert_expr): Likewise. (convert_for_assignment): Likewise. * d-lang.cc (d_classify_record): Likewise. (d_build_eh_runtime_type): Likewise. * decl.cc (DeclVisitor::visit): Likewise. * expr.cc (ExprVisitor::needs_postblit): Likewise. (ExprVisitor::needs_dtor): Likewise. (ExprVisitor::visit): Likewise. * imports.cc (ImportVisitor::visit): Likewise. * typeinfo.cc (get_typeinfo_kind): Likewise. (TypeInfoVisitor::visit): Likewise. (TypeDeclInfoVisitor::visit): Likewise. * types.cc (merge_aggregate_types): Likewise. (TypeVisitor::visit): Likewise.
Diffstat (limited to 'gcc/d/d-codegen.cc')
-rw-r--r--gcc/d/d-codegen.cc24
1 files changed, 9 insertions, 15 deletions
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 83e757d..1bf74e1 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -319,7 +319,7 @@ get_array_length (tree exp, Type *type)
switch (tb->ty)
{
case Tsarray:
- return size_int (((TypeSArray *) tb)->dim->toUInteger ());
+ return size_int (tb->isTypeSArray ()->dim->toUInteger ());
case Tarray:
return d_array_length (exp);
@@ -812,9 +812,8 @@ identity_compare_p (StructDeclaration *sd)
Type *tb = vd->type->toBasetype ();
/* Check inner data structures. */
- if (tb->ty == Tstruct)
+ if (TypeStruct *ts = tb->isTypeStruct ())
{
- TypeStruct *ts = (TypeStruct *) tb;
if (!identity_compare_p (ts->sym))
return false;
}
@@ -897,11 +896,10 @@ lower_struct_comparison (tree_code code, StructDeclaration *sd,
tree t2ref = component_ref (t2, sfield);
tree tcmp;
- if (type->ty == Tstruct)
+ if (TypeStruct *ts = type->isTypeStruct ())
{
/* Compare inner data structures. */
- StructDeclaration *decl = ((TypeStruct *) type)->sym;
- tcmp = lower_struct_comparison (code, decl, t1ref, t2ref);
+ tcmp = lower_struct_comparison (code, ts->sym, t1ref, t2ref);
}
else if (type->ty != Tvector && type->isintegral ())
{
@@ -1680,15 +1678,13 @@ build_array_set (tree ptr, tree length, tree value)
tree
build_array_from_val (Type *type, tree val)
{
- gcc_assert (type->ty == Tsarray);
-
tree etype = build_ctype (type->nextOf ());
/* Initializing a multidimensional array. */
if (TREE_CODE (etype) == ARRAY_TYPE && TREE_TYPE (val) != etype)
val = build_array_from_val (type->nextOf (), val);
- size_t dims = ((TypeSArray *) type)->dim->toInteger ();
+ size_t dims = type->isTypeSArray ()->dim->toInteger ();
vec<constructor_elt, va_gc> *elms = NULL;
vec_safe_reserve (elms, dims);
@@ -1762,8 +1758,7 @@ array_bounds_check (void)
fd = d_function_chain->function;
if (fd && fd->type->ty == Tfunction)
{
- TypeFunction *tf = (TypeFunction *) fd->type;
- if (tf->trust == TRUSTsafe)
+ if (fd->type->isTypeFunction ()->trust == TRUSTsafe)
return true;
}
return false;
@@ -1783,9 +1778,9 @@ get_function_type (Type *t)
if (t->ty == Tpointer)
t = t->nextOf ()->toBasetype ();
if (t->ty == Tfunction)
- tf = (TypeFunction *) t;
+ tf = t->isTypeFunction ();
else if (t->ty == Tdelegate)
- tf = (TypeFunction *) ((TypeDelegate *) t)->next;
+ tf = t->isTypeDelegate ()->next->isTypeFunction ();
return tf;
}
@@ -1916,8 +1911,7 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
if (TREE_ADDRESSABLE (TREE_TYPE (targ)))
{
Type *t = arg->type->toBasetype ();
- gcc_assert (t->ty == Tstruct);
- StructDeclaration *sd = ((TypeStruct *) t)->sym;
+ StructDeclaration *sd = t->isTypeStruct ()->sym;
/* Nested structs also have ADDRESSABLE set, but if the type has
neither a copy constructor nor a destructor available, then we