diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2013-07-12 22:05:26 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2013-07-12 22:05:26 +0000 |
commit | c6036aa83127c50162735e8a343623f03a3211fb (patch) | |
tree | 20944fe3218e35c5490d893173cf5f0eff6d8f0d /clang/lib/CodeGen | |
parent | e07b7a9f0251b7c64a7240503d970ddc26b56c45 (diff) | |
download | bcm5719-llvm-c6036aa83127c50162735e8a343623f03a3211fb.tar.gz bcm5719-llvm-c6036aa83127c50162735e8a343623f03a3211fb.zip |
Compute 'this' correctly for block in lambda.
Using CurFuncDecl is both correct and simple compared to crawling
the DeclContexts of the block.
Fixes <rdar://problem/14415072>.
llvm-svn: 186210
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 8cc4891cc7f..eb1afa69559 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -355,14 +355,9 @@ static void computeBlockInfo(CodeGenModule &CGM, CodeGenFunction *CGF, // First, 'this'. if (block->capturesCXXThis()) { - const DeclContext *DC = block->getDeclContext(); - for (; isa<BlockDecl>(DC); DC = cast<BlockDecl>(DC)->getDeclContext()) - ; - QualType thisType; - if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) - thisType = C.getPointerType(C.getRecordType(RD)); - else - thisType = cast<CXXMethodDecl>(DC)->getThisType(C); + assert(CGF && CGF->CurFuncDecl && isa<CXXMethodDecl>(CGF->CurFuncDecl) && + "Can't capture 'this' outside a method"); + QualType thisType = cast<CXXMethodDecl>(CGF->CurFuncDecl)->getThisType(C); llvm::Type *llvmType = CGM.getTypes().ConvertType(thisType); std::pair<CharUnits,CharUnits> tinfo |