summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.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/SemaExpr.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/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp50
1 files changed, 19 insertions, 31 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d0b27602846..72b61b8e584 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14610,9 +14610,7 @@ namespace {
// context so never needs to be transformed.
// FIXME: Ideally we wouldn't transform the closure type either, and would
// just recreate the capture expressions and lambda expression.
- StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
- return SkipLambdaBody(E, Body);
- }
+ StmtResult TransformLambdaBody(Stmt *Body) { return Body; }
};
}
@@ -15056,7 +15054,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
/// *FunctionScopeIndexToStopAt on the FunctionScopeInfo stack.
static void
MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef,
- const unsigned *const FunctionScopeIndexToStopAt = nullptr) {
+ const unsigned *const FunctionScopeIndexToStopAt) {
// Keep track of used but undefined variables.
// FIXME: We shouldn't suppress this warning for static data members.
if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
@@ -15737,19 +15735,14 @@ void Sema::UpdateMarkingForLValueToRValue(Expr *E) {
// variable.
if (LambdaScopeInfo *LSI = getCurLambda()) {
Expr *SansParensExpr = E->IgnoreParens();
- VarDecl *Var;
- ArrayRef<VarDecl *> Vars = None;
+ VarDecl *Var = nullptr;
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
- Vars = Var = dyn_cast<VarDecl>(DRE->getFoundDecl());
+ Var = dyn_cast<VarDecl>(DRE->getFoundDecl());
else if (MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
- Vars = Var = dyn_cast<VarDecl>(ME->getMemberDecl());
- else if (auto *FPPE = dyn_cast<FunctionParmPackExpr>(SansParensExpr))
- Vars = llvm::makeArrayRef(FPPE->begin(), FPPE->end());
+ Var = dyn_cast<VarDecl>(ME->getMemberDecl());
- for (VarDecl *VD : Vars) {
- if (Var && IsVariableNonDependentAndAConstantExpression(VD, Context))
- LSI->markVariableExprAsNonODRUsed(SansParensExpr);
- }
+ if (Var && IsVariableNonDependentAndAConstantExpression(Var, Context))
+ LSI->markVariableExprAsNonODRUsed(SansParensExpr);
}
}
@@ -15774,18 +15767,20 @@ void Sema::CleanupVarDeclMarking() {
std::swap(LocalMaybeODRUseExprs, MaybeODRUseExprs);
for (Expr *E : LocalMaybeODRUseExprs) {
- if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
- MarkVarDeclODRUsed(cast<VarDecl>(DRE->getDecl()),
- DRE->getLocation(), *this);
- } else if (auto *ME = dyn_cast<MemberExpr>(E)) {
- MarkVarDeclODRUsed(cast<VarDecl>(ME->getMemberDecl()), ME->getMemberLoc(),
- *this);
- } else if (auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
- for (VarDecl *VD : *FP)
- MarkVarDeclODRUsed(VD, FP->getParameterPackLocation(), *this);
+ VarDecl *Var;
+ SourceLocation Loc;
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
+ Var = cast<VarDecl>(DRE->getDecl());
+ Loc = DRE->getLocation();
+ } else if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
+ Var = cast<VarDecl>(ME->getMemberDecl());
+ Loc = ME->getMemberLoc();
} else {
llvm_unreachable("Unexpected expression");
}
+
+ MarkVarDeclODRUsed(Var, Loc, *this,
+ /*MaxFunctionScopeIndex Pointer*/ nullptr);
}
assert(MaybeODRUseExprs.empty() &&
@@ -15794,8 +15789,7 @@ void Sema::CleanupVarDeclMarking() {
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc,
VarDecl *Var, Expr *E) {
- assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E) ||
- isa<FunctionParmPackExpr>(E)) &&
+ assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
"Invalid Expr argument to DoMarkVarDeclReferenced");
Var->setReferenced();
@@ -16028,12 +16022,6 @@ void Sema::MarkMemberReferenced(MemberExpr *E) {
MarkExprReferenced(*this, Loc, E->getMemberDecl(), E, MightBeOdrUse);
}
-/// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
-void Sema::MarkFunctionParmPackReferenced(FunctionParmPackExpr *E) {
- for (VarDecl *VD : *E)
- MarkExprReferenced(*this, E->getParameterPackLocation(), VD, E, true);
-}
-
/// Perform marking for a reference to an arbitrary declaration. It
/// marks the declaration referenced, and performs odr-use checking for
/// functions and variables. This method should not be used when building a
OpenPOWER on IntegriCloud