summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-02-28 01:08:45 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-02-28 01:08:45 +0000
commitec75fec805a7dec0c9a4e29bebdeca0bc8ad1e5b (patch)
treecefa25fde09e13e87ff76511398adae0fead008e /clang/lib/CodeGen/CGObjC.cpp
parent3bc5372fae18be64a7e482f0167f4b4a215dea44 (diff)
downloadbcm5719-llvm-ec75fec805a7dec0c9a4e29bebdeca0bc8ad1e5b.tar.gz
bcm5719-llvm-ec75fec805a7dec0c9a4e29bebdeca0bc8ad1e5b.zip
Implement IRGen for the retain-autorelease in the lambda conversion-to-block-pointer outside of ARC. Testcases coming up soon.
llvm-svn: 151603
Diffstat (limited to 'clang/lib/CodeGen/CGObjC.cpp')
-rw-r--r--clang/lib/CodeGen/CGObjC.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 9792017a062..9eb58fc603c 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -2774,5 +2774,30 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
return HelperFn;
}
+llvm::Value *
+CodeGenFunction::EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty) {
+ // Get selectors for retain/autorelease.
+ IdentifierInfo *RetainID = &getContext().Idents.get("retain");
+ Selector RetainSelector =
+ getContext().Selectors.getNullarySelector(RetainID);
+ IdentifierInfo *AutoreleaseID = &getContext().Idents.get("autorelease");
+ Selector AutoreleaseSelector =
+ getContext().Selectors.getNullarySelector(AutoreleaseID);
+
+ // Emit calls to retain/autorelease.
+ CGObjCRuntime &Runtime = CGM.getObjCRuntime();
+ llvm::Value *Val = Block;
+ RValue Result;
+ Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(),
+ Ty, RetainSelector,
+ Val, CallArgList(), 0, 0);
+ Val = Result.getScalarVal();
+ Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(),
+ Ty, AutoreleaseSelector,
+ Val, CallArgList(), 0, 0);
+ Val = Result.getScalarVal();
+ return Val;
+}
+
CGObjCRuntime::~CGObjCRuntime() {}
OpenPOWER on IntegriCloud