Example #1
0
LLConstant *IrAggr::getDefaultInitializer(VarDeclaration *field) {
  if (field->_init) {
    // Issue 9057 workaround caused by issue 14666 fix, see DMD upstream
    // commit 069f570005.
    if (field->sem < Semantic2Done && field->_scope) {
      field->semantic2(field->_scope);
    }
    return DtoConstInitializer(field->_init->loc, field->type, field->_init);
  }

  return DtoConstExpInit(field->loc, field->type,
                         field->type->defaultInit(field->loc));
}
Example #2
0
// helper function that returns the static default initializer of a variable
LLConstant* get_default_initializer(VarDeclaration* vd, Initializer* init)
{
    if (init)
    {
        return DtoConstInitializer(init->loc, vd->type, init);
    }

    if (vd->init)
    {
        return DtoConstInitializer(vd->init->loc, vd->type, vd->init);
    }

    if (vd->type->size(vd->loc) == 0)
    {
        // We need to be able to handle void[0] struct members even if void has
        // no default initializer.
        return llvm::ConstantPointerNull::get(DtoPtrToType(vd->type));
    }
    return DtoConstExpInit(vd->loc, vd->type, vd->type->defaultInit(vd->loc));
}