From 9dc6eef755c756db67552eccd5f2e910d8d504b3 Mon Sep 17 00:00:00 2001 From: Stephen Lin Date: Sun, 30 Jun 2013 20:40:16 +0000 Subject: Restore r184205 and associated commits (after commit of r185290) This allows clang to use the backend parameter attribute 'returned' when generating 'this'-returning constructors and destructors in ARM and MSVC C++ ABIs. llvm-svn: 185291 --- clang/lib/CodeGen/CodeGenModule.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index efff4b118d59..3298d5a0899d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -722,6 +722,14 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, if (!IsIncompleteFunction) SetLLVMFunctionAttributes(FD, getTypes().arrangeGlobalDeclaration(GD), F); + if (getCXXABI().HasThisReturn(GD)) { + assert(!F->arg_empty() && + F->arg_begin()->getType() + ->canLosslesslyBitCastTo(F->getReturnType()) && + "unexpected this return"); + F->addAttribute(1, llvm::Attribute::Returned); + } + // Only a few attributes are set on declarations; these may later be // overridden by a definition. -- cgit v1.2.3