From 2e7884a80db5b7f65b07cf5651ff9f32dee40c72 Mon Sep 17 00:00:00 2001 From: kai Date: Wed, 24 Apr 2013 07:17:45 +0200 Subject: [PATCH] Add support for new parameter attribute `returned`. Starting with LLVM 3.3 a new parameter attribute `returned` is supported. The attribute states that the parameter is the return value, too. This is the case in constructors. (Destructors and postblits do not return `this`.) Attribute `returned` is now added to the `this` parameter of constructors. --- gen/functions.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gen/functions.cpp b/gen/functions.cpp index 4b1bcb3b..3d5f84c3 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -129,7 +129,16 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, // member functions if (thistype) { - fty.arg_this = new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct); +#if LDC_LLVM_VER >= 303 + llvm::AttrBuilder attrBuilder; + if (f->funcdecl && f->funcdecl->isCtorDeclaration()) + attrBuilder.addAttribute(llvm::Attribute::Returned); +#endif + fty.arg_this = new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct +#if LDC_LLVM_VER >= 303 + , attrBuilder +#endif + ); lidx++; }