When instantiating a block expression, the instantiated

blockScopeInfo's CapturesCXXThis field need get set as
well. // rdar://9362021. John M. please review.

llvm-svn: 130930
This commit is contained in:
Fariborz Jahanian 2011-05-05 17:18:12 +00:00
parent 979aba5d09
commit 4cc5df700e
2 changed files with 39 additions and 2 deletions

View File

@ -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();

View File

@ -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(); }();
}