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/ScopeInfo.cpp | |
parent | e925be1339052b2f363d1b708370a45868fada04 (diff) | |
download | llvm-30116531b8a9acc0b25648f9e27c11265d149d60.tar.gz |
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/ScopeInfo.cpp')
-rw-r--r-- | clang/lib/Sema/ScopeInfo.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp index 1003d2639c0e..dd309a281185 100644 --- a/clang/lib/Sema/ScopeInfo.cpp +++ b/clang/lib/Sema/ScopeInfo.cpp @@ -113,17 +113,9 @@ FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(const Expr *E) { } bool CapturingScopeInfo::isVLATypeCaptured(const VariableArrayType *VAT) const { - RecordDecl *RD = nullptr; - if (auto *LSI = dyn_cast<LambdaScopeInfo>(this)) - RD = LSI->Lambda; - else if (auto CRSI = dyn_cast<CapturedRegionScopeInfo>(this)) - RD = CRSI->TheRecordDecl; - - if (RD) - for (auto *FD : RD->fields()) { - if (FD->hasCapturedVLAType() && FD->getCapturedVLAType() == VAT) - return true; - } + for (auto &Cap : Captures) + if (Cap.isVLATypeCapture() && Cap.getCapturedVLAType() == VAT) + return true; return false; } |