Author: fjahanian
Date: Thu May 5 12:18:12 2011
New Revision: 130930
URL: http://llvm.org/viewvc/llvm-project?rev=130930&view=rev
Log:
When instantiating a block expression, the instantiated
blockScopeInfo's CapturesCXXThis field need get set as
well. // rdar://9362021. John M. please review.
Added:
cfe/trunk/test/CodeGenObjCXX/block-in-template-inst.mm
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=130930&r1=130929&r2=130930&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu May 5 12:18:12 2011
@@ -7700,6 +7700,11 @@
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 @@
// 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();
Added: cfe/trunk/test/CodeGenObjCXX/block-in-template-inst.mm
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-in-template-inst.mm?rev=130930&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/block-in-template-inst.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/block-in-template-inst.mm Thu May 5 12:18:12
2011
@@ -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(); }();
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits