diff options
author | John McCall <rjmccall@apple.com> | 2011-02-07 10:33:21 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-02-07 10:33:21 +0000 |
commit | 6b5a61b6dc400027fd793dcadceeb9da944a37ea (patch) | |
tree | 8fd6aca5e8914908e0ee03c007988ea87219d2b8 /lib/Serialization/ASTWriterDecl.cpp | |
parent | 683564a7a93c952f1fbe573b55c542418d29d859 (diff) |
A few more tweaks to the blocks AST representation:
- BlockDeclRefExprs always store VarDecls
- BDREs no longer store copy expressions
- BlockDecls now store a list of captured variables, information about
how they're captured, and a copy expression if necessary
With that in hand, change IR generation to use the captures data in
blocks instead of walking the block independently.
Additionally, optimize block layout by emitting fields in descending
alignment order, with a heuristic for filling in words when alignment
of the end of the block header is insufficient for the most aligned
field.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 1fe6398b73..3e57de11c8 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -624,10 +624,20 @@ void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) { P != PEnd; ++P) Writer.AddDeclRef(*P, Record); Record.push_back(D->capturesCXXThis()); - Record.push_back(D->getNumCapturedDecls()); + Record.push_back(D->getNumCaptures()); for (BlockDecl::capture_iterator - i = D->capture_begin(), e = D->capture_end(); i != e; ++i) - Writer.AddDeclRef(*i, Record); + i = D->capture_begin(), e = D->capture_end(); i != e; ++i) { + const BlockDecl::Capture &capture = *i; + Writer.AddDeclRef(capture.getVariable(), Record); + + unsigned flags = 0; + if (capture.isByRef()) flags |= 1; + if (capture.isNested()) flags |= 2; + if (capture.hasCopyExpr()) flags |= 4; + Record.push_back(flags); + + if (capture.hasCopyExpr()) Writer.AddStmt(capture.getCopyExpr()); + } Code = serialization::DECL_BLOCK; } |