diff options
author | John McCall <rjmccall@apple.com> | 2010-05-20 01:18:31 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-05-20 01:18:31 +0000 |
commit | 87fe5d561815de46450813c3d50e9c338c97dc1e (patch) | |
tree | fbe116d7c0893e6fce12932c89dad90daf4880e8 /clang/lib/CodeGen/CGBlocks.h | |
parent | 1d881510791582a045d0f178779fc486295f9eb2 (diff) | |
download | bcm5719-llvm-87fe5d561815de46450813c3d50e9c338c97dc1e.tar.gz bcm5719-llvm-87fe5d561815de46450813c3d50e9c338c97dc1e.zip |
Support implicitly closing on 'this' in a block. Fixed PR7165.
(the codegen works here, too, but that's annoying to test without execution)
llvm-svn: 104202
Diffstat (limited to 'clang/lib/CodeGen/CGBlocks.h')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.h | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.h b/clang/lib/CodeGen/CGBlocks.h index 5646d0036e9..067dfc7fdfd 100644 --- a/clang/lib/CodeGen/CGBlocks.h +++ b/clang/lib/CodeGen/CGBlocks.h @@ -160,8 +160,12 @@ public: /// into this block. llvm::SmallVector<const BlockDeclRefExpr *, 8> DeclRefs; + /// CXXThisRef - An expression referring to the required 'this' + /// expression. + const CXXThisExpr *CXXThisRef; + BlockInfo(const llvm::Type *blt, const char *n) - : BlockLiteralTy(blt), Name(n) { + : BlockLiteralTy(blt), Name(n), CXXThisRef(0) { // Skip asm prefix, if any. if (Name && Name[0] == '\01') ++Name; @@ -179,19 +183,31 @@ public: /// characters. CharUnits BlockAlign; - /// getBlockOffset - Allocate an offset for the ValueDecl from a - /// BlockDeclRefExpr in a block literal (BlockExpr). - CharUnits getBlockOffset(const BlockDeclRefExpr *E); + /// getBlockOffset - Allocate a location within the block's storage + /// for a value with the given size and alignment requirements. + CharUnits getBlockOffset(CharUnits Size, CharUnits Align); /// BlockHasCopyDispose - True iff the block uses copy/dispose. bool BlockHasCopyDispose; - /// BlockDeclRefDecls - Decls from BlockDeclRefExprs in apperance order - /// in a block literal. Decls without names are used for padding. - llvm::SmallVector<const Expr *, 8> BlockDeclRefDecls; + /// BlockLayout - The layout of the block's storage, represented as + /// a sequence of expressions which require such storage. The + /// expressions can be: + /// - a BlockDeclRefExpr, indicating that the given declaration + /// from an enclosing scope is needed by the block; + /// - a DeclRefExpr, which always wraps an anonymous VarDecl with + /// array type, used to insert padding into the block; or + /// - a CXXThisExpr, indicating that the C++ 'this' value should + /// propagate from the parent to the block. + /// This is a really silly representation. + llvm::SmallVector<const Expr *, 8> BlockLayout; /// BlockDecls - Offsets for all Decls in BlockDeclRefExprs. - std::map<const Decl*, CharUnits> BlockDecls; + llvm::DenseMap<const Decl*, CharUnits> BlockDecls; + + /// BlockCXXThisOffset - The offset of the C++ 'this' value within + /// the block structure. + CharUnits BlockCXXThisOffset; ImplicitParamDecl *BlockStructDecl; ImplicitParamDecl *getBlockStructDecl() { return BlockStructDecl; } |