From 8fea7484fe52fd748d4800ee191ba0f7cc07087c Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Sat, 5 Oct 2013 17:34:29 +0400 Subject: [PATCH] Don't use TypeFunction::funcdecl as it is about to be removed --- gen/functions.cpp | 10 +++++----- gen/functions.h | 2 +- ir/irtype.cpp | 22 ---------------------- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/gen/functions.cpp b/gen/functions.cpp index 986bcc46..7e0122a1 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -40,7 +40,7 @@ using namespace llvm::Attribute; #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()) Logger::println("DtoFunctionType(%s)", type->toChars()); @@ -62,7 +62,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype, size_t lidx = 0; // main needs a little special handling - if (ismain) + if (isMain) { 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 llvm::AttrBuilder attrBuilder; - if (f->funcdecl && f->funcdecl->isCtorDeclaration()) + if (isCtor) attrBuilder.addAttribute(llvm::Attribute::Returned); #endif 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 int nargs = Parameter::dim(f->parameters); - if (ismain && nargs == 0) + if (isMain && nargs == 0) { Type* mainargs = Type::tchar->arrayOf()->arrayOf(); newIrFty.args.push_back(new IrFuncTyArg(mainargs, false)); @@ -434,7 +434,7 @@ llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl) 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; } diff --git a/gen/functions.h b/gen/functions.h index 4bef2e65..7c413ebd 100644 --- a/gen/functions.h +++ b/gen/functions.h @@ -29,7 +29,7 @@ namespace llvm 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* DtoBaseFunctionType(FuncDeclaration* fdecl); diff --git a/ir/irtype.cpp b/ir/irtype.cpp index a155064d..ff917b4f 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -166,28 +166,6 @@ IrTypePointer* IrTypePointer::get(Type* dt) } else { - if (dt->nextOf()->ty == Tfunction) - { - TypeFunction* tf = static_cast(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()))); // DtoType could have already created the same type, e.g. for