summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/ScopeInfo.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-06-03 09:56:09 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-06-03 09:56:09 +0000
commitc716e5d6dea2dec44e2f54da5a7ec41b1237011b (patch)
tree52829a4c74b665e81318cc52ab7ea09cfb626b53 /clang/lib/Sema/ScopeInfo.cpp
parent1115a199aaec146972419749db7b10cfe832801a (diff)
downloadbcm5719-llvm-c716e5d6dea2dec44e2f54da5a7ec41b1237011b.tar.gz
bcm5719-llvm-c716e5d6dea2dec44e2f54da5a7ec41b1237011b.zip
Revert rL362358 : PR42104: Support instantiations of lambdas that implicitly capture packs.
Two changes: * Track odr-use via FunctionParmPackExprs to properly handle dependent odr-uses of packs in generic lambdas. * Do not instantiate implicit captures; instead, regenerate them by instantiating the body of the lambda. This is necessary to distinguish between cases where only one element of a pack is captured and cases where the entire pack is captured. ........ Fixes http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win buildbot failures llvm-svn: 362375
Diffstat (limited to 'clang/lib/Sema/ScopeInfo.cpp')
-rw-r--r--clang/lib/Sema/ScopeInfo.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp
index b2a26af9b4a..e84e592a482 100644
--- a/clang/lib/Sema/ScopeInfo.cpp
+++ b/clang/lib/Sema/ScopeInfo.cpp
@@ -229,20 +229,20 @@ bool CapturingScopeInfo::isVLATypeCaptured(const VariableArrayType *VAT) const {
return false;
}
-void LambdaScopeInfo::visitPotentialCaptures(
- llvm::function_ref<void(VarDecl *, Expr *)> Callback) const {
- for (Expr *E : PotentiallyCapturingExprs) {
- if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
- Callback(cast<VarDecl>(DRE->getFoundDecl()), E);
- } else if (auto *ME = dyn_cast<MemberExpr>(E)) {
- Callback(cast<VarDecl>(ME->getMemberDecl()), E);
- } else if (auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
- for (VarDecl *VD : *FP)
- Callback(VD, E);
- } else {
- llvm_unreachable("unexpected expression in potential captures list");
- }
- }
+void LambdaScopeInfo::getPotentialVariableCapture(unsigned Idx, VarDecl *&VD,
+ Expr *&E) const {
+ assert(Idx < getNumPotentialVariableCaptures() &&
+ "Index of potential capture must be within 0 to less than the "
+ "number of captures!");
+ E = PotentiallyCapturingExprs[Idx];
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
+ VD = dyn_cast<VarDecl>(DRE->getFoundDecl());
+ else if (MemberExpr *ME = dyn_cast<MemberExpr>(E))
+ VD = dyn_cast<VarDecl>(ME->getMemberDecl());
+ else
+ llvm_unreachable("Only DeclRefExprs or MemberExprs should be added for "
+ "potential captures");
+ assert(VD);
}
FunctionScopeInfo::~FunctionScopeInfo() { }
OpenPOWER on IntegriCloud