From 3a08c1cd3bb40eaabc096697389b8507c719092b Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 24 Feb 2012 17:41:38 +0000 Subject: Two minor, related fixes for template instantiation with blocks: - Make sure that the block expression is instantiation-dependent if the block is in a dependent context - Make sure that the C++ 'this' expression gets captured even if we don't rebuild the AST node during template instantiation. This would also have manifested as a bug for lambdas. Fixes . llvm-svn: 151372 --- clang/lib/Sema/TreeTransform.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema') diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index f0b5f4e2419..11f03fc133a 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -7038,9 +7038,12 @@ TreeTransform::TransformCXXThisExpr(CXXThisExpr *E) { T = getSema().Context.getPointerType( getSema().Context.getRecordType(cast(DC))); - if (!getDerived().AlwaysRebuild() && T == E->getType()) + if (!getDerived().AlwaysRebuild() && T == E->getType()) { + // Make sure that we capture 'this'. + getSema().CheckCXXThisCapture(E->getLocStart()); return SemaRef.Owned(E); - + } + return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit()); } @@ -8539,6 +8542,7 @@ TreeTransform::TransformBlockExpr(BlockExpr *E) { oldCapture)); assert(blockScope->CaptureMap.count(newCapture)); } + assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured()); } #endif -- cgit v1.2.3