@@ -14610,7 +14610,9 @@ namespace {
1461014610 // context so never needs to be transformed.
1461114611 // FIXME: Ideally we wouldn't transform the closure type either, and would
1461214612 // just recreate the capture expressions and lambda expression.
14613- StmtResult TransformLambdaBody(Stmt *Body) { return Body; }
14613+ StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
14614+ return SkipLambdaBody(E, Body);
14615+ }
1461414616 };
1461514617}
1461614618
@@ -15054,7 +15056,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
1505415056/// *FunctionScopeIndexToStopAt on the FunctionScopeInfo stack.
1505515057static void
1505615058MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef,
15057- const unsigned *const FunctionScopeIndexToStopAt) {
15059+ const unsigned *const FunctionScopeIndexToStopAt = nullptr ) {
1505815060 // Keep track of used but undefined variables.
1505915061 // FIXME: We shouldn't suppress this warning for static data members.
1506015062 if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
@@ -15735,14 +15737,21 @@ void Sema::UpdateMarkingForLValueToRValue(Expr *E) {
1573515737 // variable.
1573615738 if (LambdaScopeInfo *LSI = getCurLambda()) {
1573715739 Expr *SansParensExpr = E->IgnoreParens();
15738- VarDecl *Var = nullptr;
15740+ VarDecl *Var;
15741+ ArrayRef<VarDecl *> Vars(&Var, &Var + 1);
1573915742 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
1574015743 Var = dyn_cast<VarDecl>(DRE->getFoundDecl());
1574115744 else if (MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
1574215745 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
15746+ else if (auto *FPPE = dyn_cast<FunctionParmPackExpr>(SansParensExpr))
15747+ Vars = llvm::makeArrayRef(FPPE->begin(), FPPE->end());
15748+ else
15749+ Vars = None;
1574315750
15744- if (Var && IsVariableNonDependentAndAConstantExpression(Var, Context))
15745- LSI->markVariableExprAsNonODRUsed(SansParensExpr);
15751+ for (VarDecl *VD : Vars) {
15752+ if (VD && IsVariableNonDependentAndAConstantExpression(VD, Context))
15753+ LSI->markVariableExprAsNonODRUsed(SansParensExpr);
15754+ }
1574615755 }
1574715756}
1574815757
@@ -15767,20 +15776,18 @@ void Sema::CleanupVarDeclMarking() {
1576715776 std::swap(LocalMaybeODRUseExprs, MaybeODRUseExprs);
1576815777
1576915778 for (Expr *E : LocalMaybeODRUseExprs) {
15770- VarDecl *Var;
15771- SourceLocation Loc;
15772- if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
15773- Var = cast<VarDecl>(DRE->getDecl());
15774- Loc = DRE->getLocation();
15775- } else if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
15776- Var = cast<VarDecl>(ME->getMemberDecl());
15777- Loc = ME->getMemberLoc();
15779+ if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
15780+ MarkVarDeclODRUsed(cast<VarDecl>(DRE->getDecl()),
15781+ DRE->getLocation(), *this);
15782+ } else if (auto *ME = dyn_cast<MemberExpr>(E)) {
15783+ MarkVarDeclODRUsed(cast<VarDecl>(ME->getMemberDecl()), ME->getMemberLoc(),
15784+ *this);
15785+ } else if (auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
15786+ for (VarDecl *VD : *FP)
15787+ MarkVarDeclODRUsed(VD, FP->getParameterPackLocation(), *this);
1577815788 } else {
1577915789 llvm_unreachable("Unexpected expression");
1578015790 }
15781-
15782- MarkVarDeclODRUsed(Var, Loc, *this,
15783- /*MaxFunctionScopeIndex Pointer*/ nullptr);
1578415791 }
1578515792
1578615793 assert(MaybeODRUseExprs.empty() &&
@@ -15789,7 +15796,8 @@ void Sema::CleanupVarDeclMarking() {
1578915796
1579015797static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc,
1579115798 VarDecl *Var, Expr *E) {
15792- assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
15799+ assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E) ||
15800+ isa<FunctionParmPackExpr>(E)) &&
1579315801 "Invalid Expr argument to DoMarkVarDeclReferenced");
1579415802 Var->setReferenced();
1579515803
@@ -16022,6 +16030,12 @@ void Sema::MarkMemberReferenced(MemberExpr *E) {
1602216030 MarkExprReferenced(*this, Loc, E->getMemberDecl(), E, MightBeOdrUse);
1602316031}
1602416032
16033+ /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
16034+ void Sema::MarkFunctionParmPackReferenced(FunctionParmPackExpr *E) {
16035+ for (VarDecl *VD : *E)
16036+ MarkExprReferenced(*this, E->getParameterPackLocation(), VD, E, true);
16037+ }
16038+
1602516039/// Perform marking for a reference to an arbitrary declaration. It
1602616040/// marks the declaration referenced, and performs odr-use checking for
1602716041/// functions and variables. This method should not be used when building a
0 commit comments