@@ -2696,7 +2696,7 @@ PreCheckFunctionBodyRequest::evaluate(Evaluator &evaluator,
26962696 // single expression return, do so now.
26972697 if (!func->getResultInterfaceType ()->isVoid ()) {
26982698 if (auto *S = body->getSingleActiveStatement ()) {
2699- if (S->mayProduceSingleValue (evaluator )) {
2699+ if (S->mayProduceSingleValue (ctx )) {
27002700 auto *SVE = SingleValueStmtExpr::createWithWrappedBranches (
27012701 ctx, S, /* DC*/ func, /* mustBeExpr*/ false );
27022702 auto *RS = new (ctx) ReturnStmt (SourceLoc (), SVE);
@@ -2943,7 +2943,7 @@ static bool doesBraceEndWithThrow(BraceStmt *BS) {
29432943
29442944// / Whether the given brace statement is considered to produce a result for
29452945// / an if/switch expression.
2946- static bool doesBraceProduceResult (BraceStmt *BS, Evaluator &eval ) {
2946+ static bool doesBraceProduceResult (BraceStmt *BS, ASTContext &ctx ) {
29472947 if (BS->empty ())
29482948 return false ;
29492949
@@ -2955,14 +2955,14 @@ static bool doesBraceProduceResult(BraceStmt *BS, Evaluator &eval) {
29552955 return true ;
29562956
29572957 if (auto *S = BS->getSingleActiveStatement ()) {
2958- if (S->mayProduceSingleValue (eval ))
2958+ if (S->mayProduceSingleValue (ctx ))
29592959 return true ;
29602960 }
29612961 return SingleValueStmtExpr::hasResult (BS);
29622962}
29632963
29642964IsSingleValueStmtResult
2965- areBranchesValidForSingleValueStmt (Evaluator &eval , ArrayRef<Stmt *> branches) {
2965+ areBranchesValidForSingleValueStmt (ASTContext &ctx , ArrayRef<Stmt *> branches) {
29662966 TinyPtrVector<Stmt *> invalidJumps;
29672967 TinyPtrVector<Stmt *> unterminatedBranches;
29682968 JumpOutOfContextFinder jumpFinder (invalidJumps);
@@ -2979,7 +2979,7 @@ areBranchesValidForSingleValueStmt(Evaluator &eval, ArrayRef<Stmt *> branches) {
29792979 BS->walk (jumpFinder);
29802980
29812981 // Check to see if a result is produced from the branch.
2982- if (doesBraceProduceResult (BS, eval )) {
2982+ if (doesBraceProduceResult (BS, ctx )) {
29832983 hadResult = true ;
29842984 continue ;
29852985 }
@@ -3005,7 +3005,11 @@ areBranchesValidForSingleValueStmt(Evaluator &eval, ArrayRef<Stmt *> branches) {
30053005}
30063006
30073007IsSingleValueStmtResult
3008- IsSingleValueStmtRequest::evaluate (Evaluator &eval, const Stmt *S) const {
3008+ IsSingleValueStmtRequest::evaluate (Evaluator &eval, const Stmt *S,
3009+ ASTContext *_ctx) const {
3010+ assert (_ctx);
3011+ auto &ctx = *_ctx;
3012+
30093013 if (!isa<IfStmt>(S) && !isa<SwitchStmt>(S))
30103014 return IsSingleValueStmtResult::unhandledStmt ();
30113015
@@ -3020,11 +3024,11 @@ IsSingleValueStmtRequest::evaluate(Evaluator &eval, const Stmt *S) const {
30203024 return IsSingleValueStmtResult::nonExhaustiveIf ();
30213025
30223026 SmallVector<Stmt *, 4 > scratch;
3023- return areBranchesValidForSingleValueStmt (eval , IS->getBranches (scratch));
3027+ return areBranchesValidForSingleValueStmt (ctx , IS->getBranches (scratch));
30243028 }
30253029 if (auto *SS = dyn_cast<SwitchStmt>(S)) {
30263030 SmallVector<Stmt *, 4 > scratch;
3027- return areBranchesValidForSingleValueStmt (eval , SS->getBranches (scratch));
3031+ return areBranchesValidForSingleValueStmt (ctx , SS->getBranches (scratch));
30283032 }
30293033 llvm_unreachable (" Unhandled case" );
30303034}
0 commit comments