diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-31 00:45:10 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-31 00:45:10 +0000 |
commit | 0621a8f353631c72e497dba01790b39f83943679 (patch) | |
tree | c4dbd8e392f5c177ca2477e670bf8c68f99d3db5 /clang/lib/Sema/ScopeInfo.cpp | |
parent | 2fdd95c1c823ebafc9286f7b730339c38636c5a8 (diff) | |
download | bcm5719-llvm-0621a8f353631c72e497dba01790b39f83943679.tar.gz bcm5719-llvm-0621a8f353631c72e497dba01790b39f83943679.zip |
Defer capture initialization for captured regions until after we've left
the captured region scope.
This removes a case where we would build expressions (and mark
declarations odr-used) in the wrong scope.
Remove the now-unused 'capture initializer' field on sema::Capture
(except for 'this' captures, which still need to be cleaned up).
No functionality change intended (except that we now very slightly more
precisely determine whether we need to use a capture or not when another
captured region encloses an OpenMP captured region).
llvm-svn: 362179
Diffstat (limited to 'clang/lib/Sema/ScopeInfo.cpp')
-rw-r--r-- | clang/lib/Sema/ScopeInfo.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp index dd309a28118..e84e592a482 100644 --- a/clang/lib/Sema/ScopeInfo.cpp +++ b/clang/lib/Sema/ScopeInfo.cpp @@ -112,13 +112,6 @@ FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(const Expr *E) { return BaseInfoTy(D, IsExact); } -bool CapturingScopeInfo::isVLATypeCaptured(const VariableArrayType *VAT) const { - for (auto &Cap : Captures) - if (Cap.isVLATypeCapture() && Cap.getCapturedVLAType() == VAT) - return true; - return false; -} - FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy( const ObjCPropertyRefExpr *PropE) : Base(nullptr, true), Property(getBestPropertyDecl(PropE)) { @@ -223,6 +216,19 @@ void FunctionScopeInfo::markSafeWeakUse(const Expr *E) { ThisUse->markSafe(); } +bool Capture::isInitCapture() const { + // Note that a nested capture of an init-capture is not itself an + // init-capture. + return !isNested() && isVariableCapture() && getVariable()->isInitCapture(); +} + +bool CapturingScopeInfo::isVLATypeCaptured(const VariableArrayType *VAT) const { + for (auto &Cap : Captures) + if (Cap.isVLATypeCapture() && Cap.getCapturedVLAType() == VAT) + return true; + return false; +} + void LambdaScopeInfo::getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) const { assert(Idx < getNumPotentialVariableCaptures() && |