diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-13 16:35:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-13 16:35:30 +0000 |
commit | 9daa7bfdff7256cef693d7bf10084881bcb9253c (patch) | |
tree | 8902ff401da72f1c89e61f0f6dcf47dfb0088b5c /lib/AST/DeclCXX.cpp | |
parent | 3b66d7b73536ccf8612504f1edb56fa360a73947 (diff) |
Keep track of the set of array index variables we use when we
synthesize a by-copy captured array in a lambda. This information will
be needed by IR generation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclCXX.cpp')
-rw-r--r-- | lib/AST/DeclCXX.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 257a507b23..fcd45088c2 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -38,13 +38,23 @@ AccessSpecDecl *AccessSpecDecl::CreateDeserialized(ASTContext &C, unsigned ID) { void CXXRecordDecl::LambdaDefinitionData::allocateExtra( ArrayRef<LambdaExpr::Capture> Captures, ArrayRef<Expr *> CaptureInits, + ArrayRef<VarDecl *> ArrayIndexVars, + ArrayRef<unsigned> ArrayIndexStarts, Stmt *Body) { NumCaptures = Captures.size(); NumExplicitCaptures = 0; ASTContext &Context = Definition->getASTContext(); + unsigned ArrayIndexSize = 0; + if (ArrayIndexVars.size() > 0) { + HasArrayIndexVars = true; + ArrayIndexSize = sizeof(unsigned) * (Captures.size() + 1) + + sizeof(VarDecl *) * ArrayIndexVars.size(); + } + this->Extra = Context.Allocate(sizeof(Capture) * Captures.size() + - sizeof(Stmt*) * (Captures.size() + 1)); + sizeof(Stmt*) * (Captures.size() + 1) + + ArrayIndexSize); // Copy captures. Capture *ToCapture = getCaptures(); @@ -62,6 +72,15 @@ void CXXRecordDecl::LambdaDefinitionData::allocateExtra( // Copy the body of the lambda. *Stored++ = Body; + + if (ArrayIndexVars.size() > 0) { + assert(ArrayIndexStarts.size() == Captures.size()); + memcpy(getArrayIndexVars(), ArrayIndexVars.data(), + sizeof(VarDecl *) * ArrayIndexVars.size()); + memcpy(getArrayIndexStarts(), ArrayIndexStarts.data(), + sizeof(unsigned) * Captures.size()); + getArrayIndexStarts()[Captures.size()] = ArrayIndexVars.size(); + } } |