diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-28 23:09:46 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-28 23:09:46 +0000 |
commit | 30116531b8a9acc0b25648f9e27c11265d149d60 (patch) | |
tree | 7defe572be6841f9f37770eb973703c3a5c21409 /clang/lib/Sema/SemaStmt.cpp | |
parent | e925be1339052b2f363d1b708370a45868fada04 (diff) | |
download | bcm5719-llvm-30116531b8a9acc0b25648f9e27c11265d149d60.tar.gz bcm5719-llvm-30116531b8a9acc0b25648f9e27c11265d149d60.zip |
Defer creating fields for captures until we finish building the
capturing expression or statement.
No functionality change yet. The intent is that we will also delay
building the initialization expression until the enclosing context, so
that:
a) we build the initialization expression in the right context, and
b) we can elide captures that are not odr-used, as suggested by P0588R1.
This also consolidates some duplicated code building capture fields into
a single place.
llvm-svn: 361893
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 51a72c618b7..357e257abe0 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -4224,13 +4224,16 @@ Sema::CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, } static void -buildCapturedStmtCaptureList(SmallVectorImpl<CapturedStmt::Capture> &Captures, - SmallVectorImpl<Expr *> &CaptureInits, - ArrayRef<sema::Capture> Candidates) { - for (const sema::Capture &Cap : Candidates) { +buildCapturedStmtCaptureList(Sema &S, CapturedRegionScopeInfo *RSI, + SmallVectorImpl<CapturedStmt::Capture> &Captures, + SmallVectorImpl<Expr *> &CaptureInits) { + for (const sema::Capture &Cap : RSI->Captures) { if (Cap.isInvalid()) continue; + // Create a field for this capture. + FieldDecl *Field = S.BuildCaptureField(RSI->TheRecordDecl, Cap); + if (Cap.isThisCapture()) { Captures.push_back(CapturedStmt::Capture(Cap.getLocation(), CapturedStmt::VCK_This)); @@ -4243,6 +4246,8 @@ buildCapturedStmtCaptureList(SmallVectorImpl<CapturedStmt::Capture> &Captures, continue; } + if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) + S.setOpenMPCaptureKind(Field, Cap.getVariable(), RSI->OpenMPLevel); Captures.push_back(CapturedStmt::Capture(Cap.getLocation(), Cap.isReferenceCapture() ? CapturedStmt::VCK_ByRef @@ -4360,7 +4365,7 @@ StmtResult Sema::ActOnCapturedRegionEnd(Stmt *S) { SmallVector<CapturedStmt::Capture, 4> Captures; SmallVector<Expr *, 4> CaptureInits; - buildCapturedStmtCaptureList(Captures, CaptureInits, RSI->Captures); + buildCapturedStmtCaptureList(*this, RSI, Captures, CaptureInits); CapturedDecl *CD = RSI->TheCapturedDecl; RecordDecl *RD = RSI->TheRecordDecl; |