summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/TreeTransform.h7
-rw-r--r--clang/test/CodeGenObjCXX/block-in-template-inst.mm34
2 files changed, 39 insertions, 2 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 2a71e14265a..4bb18417164 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7700,6 +7700,11 @@ TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
BlockScopeInfo *blockScope = SemaRef.getCurBlock();
blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
+ // We built a new blockScopeInfo in call to ActOnBlockStart
+ // in above, CapturesCXXThis need be set here from the block
+ // expression.
+ blockScope->CapturesCXXThis = oldBlock->capturesCXXThis();
+
llvm::SmallVector<ParmVarDecl*, 4> params;
llvm::SmallVector<QualType, 4> paramTypes;
@@ -7760,8 +7765,6 @@ TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
// In builds with assertions, make sure that we captured everything we
// captured before.
- if (oldBlock->capturesCXXThis()) assert(blockScope->CapturesCXXThis);
-
for (BlockDecl::capture_iterator i = oldBlock->capture_begin(),
e = oldBlock->capture_end(); i != e; ++i) {
VarDecl *oldCapture = i->getVariable();
diff --git a/clang/test/CodeGenObjCXX/block-in-template-inst.mm b/clang/test/CodeGenObjCXX/block-in-template-inst.mm
new file mode 100644
index 00000000000..862488ddb7e
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/block-in-template-inst.mm
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm-only -fblocks -o - -triple x86_64-apple-darwin10 %s
+// rdar://9362021
+
+@class DYFuture;
+@interface NSCache
+- (void)setObject:(id)obj forKey:(id)key;
+@end
+
+template <typename T>
+class ResourceManager
+{
+public:
+ ~ResourceManager();
+ DYFuture* XXX();
+ NSCache* _spDeviceCache;
+};
+
+template <typename T>
+DYFuture* ResourceManager<T>::XXX()
+{
+ ^ {
+ [_spDeviceCache setObject:0 forKey:0];
+ }();
+
+ return 0;
+}
+
+struct AnalyzerBaseObjectTypes { };
+
+void FUNC()
+{
+ ResourceManager<AnalyzerBaseObjectTypes> *rm;
+ ^(void) { rm->XXX(); }();
+}
OpenPOWER on IntegriCloud