summaryrefslogtreecommitdiffstats
path: root/lib/AST/DeclCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-10 07:45:31 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-10 07:45:31 +0000
commit4d8d22bfaed6e5d7da6b5556415b18c43b44e36c (patch)
treee426e3c83c502004ea93b36f96ae13503f7f3566 /lib/AST/DeclCXX.cpp
parent864b1cf13b288c5099911e1265431ffdcac060a4 (diff)
Extend CXXRecordDecl with a function that determines the mapping from
the variables captured by a lambda to the fields that store the captured values. To be used in IRgen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclCXX.cpp')
-rw-r--r--lib/AST/DeclCXX.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index aa24e9b625..b65daa5e5e 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -969,6 +969,35 @@ bool CXXRecordDecl::isCLike() const {
return isPOD() && data().HasOnlyCMembers;
}
+void CXXRecordDecl::setLambda(LambdaExpr *Lambda) {
+ if (!Lambda)
+ return;
+
+ data().IsLambda = true;
+ getASTContext().Lambdas[this] = Lambda;
+}
+
+void CXXRecordDecl::getCaptureFields(
+ llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
+ FieldDecl *&ThisCapture) {
+ Captures.clear();
+ ThisCapture = 0;
+
+ LambdaExpr *Lambda = getASTContext().Lambdas[this];
+ RecordDecl::field_iterator Field = field_begin();
+ for (LambdaExpr::capture_iterator C = Lambda->capture_begin(),
+ CEnd = Lambda->capture_end();
+ C != CEnd; ++C, ++Field) {
+ if (C->capturesThis()) {
+ ThisCapture = *Field;
+ continue;
+ }
+
+ Captures[C->getCapturedVar()] = *Field;
+ }
+}
+
+
static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) {
QualType T;
if (isa<UsingShadowDecl>(Conv))