Don't use TypeFunction::funcdecl as it is about to be removed

This commit is contained in:
Alexey Prokhin 2013-10-05 17:34:29 +04:00
parent b819975c84
commit 8fea7484fe
3 changed files with 6 additions and 28 deletions

View file

@ -40,7 +40,7 @@
using namespace llvm::Attribute; using namespace llvm::Attribute;
#endif #endif
llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, Type* nesttype, bool ismain) llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, Type* nesttype, bool isMain, bool isCtor)
{ {
if (Logger::enabled()) if (Logger::enabled())
Logger::println("DtoFunctionType(%s)", type->toChars()); Logger::println("DtoFunctionType(%s)", type->toChars());
@ -62,7 +62,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype,
size_t lidx = 0; size_t lidx = 0;
// main needs a little special handling // main needs a little special handling
if (ismain) if (isMain)
{ {
newIrFty.ret = new IrFuncTyArg(Type::tint32, false); newIrFty.ret = new IrFuncTyArg(Type::tint32, false);
} }
@ -130,7 +130,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype,
{ {
#if LDC_LLVM_VER >= 303 #if LDC_LLVM_VER >= 303
llvm::AttrBuilder attrBuilder; llvm::AttrBuilder attrBuilder;
if (f->funcdecl && f->funcdecl->isCtorDeclaration()) if (isCtor)
attrBuilder.addAttribute(llvm::Attribute::Returned); attrBuilder.addAttribute(llvm::Attribute::Returned);
#endif #endif
newIrFty.arg_this = new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct newIrFty.arg_this = new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct
@ -186,7 +186,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype,
// if this _Dmain() doesn't have an argument, we force it to have one // if this _Dmain() doesn't have an argument, we force it to have one
int nargs = Parameter::dim(f->parameters); int nargs = Parameter::dim(f->parameters);
if (ismain && nargs == 0) if (isMain && nargs == 0)
{ {
Type* mainargs = Type::tchar->arrayOf()->arrayOf(); Type* mainargs = Type::tchar->arrayOf()->arrayOf();
newIrFty.args.push_back(new IrFuncTyArg(mainargs, false)); newIrFty.args.push_back(new IrFuncTyArg(mainargs, false));
@ -434,7 +434,7 @@ llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
dnest = Type::tvoid->pointerTo(); dnest = Type::tvoid->pointerTo();
} }
LLFunctionType* functype = DtoFunctionType(fdecl->type, fdecl->irFty, dthis, dnest, fdecl->isMain()); LLFunctionType* functype = DtoFunctionType(fdecl->type, fdecl->irFty, dthis, dnest, fdecl->isMain(), fdecl->isCtorDeclaration());
return functype; return functype;
} }

View file

@ -29,7 +29,7 @@ namespace llvm
class Value; class Value;
} }
llvm::FunctionType* DtoFunctionType(Type* t, IrFuncTy &irFty, Type* thistype, Type* nesttype, bool ismain = false); llvm::FunctionType* DtoFunctionType(Type* t, IrFuncTy &irFty, Type* thistype, Type* nesttype, bool isMain = false, bool isCtor = false);
llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl); llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl);
llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl); llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl);

View file

@ -166,28 +166,6 @@ IrTypePointer* IrTypePointer::get(Type* dt)
} }
else else
{ {
if (dt->nextOf()->ty == Tfunction)
{
TypeFunction* tf = static_cast<TypeFunction*>(dt->nextOf());
if (tf->funcdecl)
{
if (FuncLiteralDeclaration* fld =
tf->funcdecl->isFuncLiteralDeclaration())
{
if (fld->tok == TOKreserved)
{
// This is the type of a lambda that was inferred to be
// a function literal instead of a delegate, so set tok
// here in order to get correct types/mangling. Horrible
// hack, but DMD does the same thing in FuncExp::toElem
// and other random places.
fld->tok = TOKfunction;
fld->vthis = NULL;
}
}
}
}
elemType = i1ToI8(voidToI8(DtoType(dt->nextOf()))); elemType = i1ToI8(voidToI8(DtoType(dt->nextOf())));
// DtoType could have already created the same type, e.g. for // DtoType could have already created the same type, e.g. for