@@ -347,23 +347,6 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
347347 return Action::SkipNode (E);
348348 }
349349
350- auto doSkipChildren = [&]() -> PreWalkResult<Expr *> {
351- // If we decide to skip the children after having issued the call to
352- // walkToExprPre, we need to simulate a corresponding call to walkToExprPost
353- // which will not be issued by the ASTWalker if we return false in the first
354- // component.
355- // TODO: We should consider changing Action::SkipChildren to still call
356- // walkToExprPost, which would eliminate the need for this.
357- auto postWalkResult = walkToExprPost (E);
358- switch (postWalkResult.Action .Action ) {
359- case PostWalkAction::Stop:
360- return Action::Stop ();
361- case PostWalkAction::Continue:
362- return Action::SkipNode (*postWalkResult.Value );
363- }
364- llvm_unreachable (" Unhandled case in switch!" );
365- };
366-
367350 if (auto *CtorRefE = dyn_cast<ConstructorRefCallExpr>(E))
368351 CtorRefs.push_back (CtorRefE);
369352
@@ -439,11 +422,11 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
439422 if (!passReference (MRE->getMember ().getDecl (), MRE->getType (),
440423 MRE->getNameLoc (),
441424 ReferenceMetaData (SemaReferenceKind::DeclMemberRef,
442- OpAccess)))
425+ OpAccess))) {
443426 return Action::Stop ();
444-
427+ }
445428 // We already visited the children.
446- return doSkipChildren ( );
429+ return Action::SkipChildren (E );
447430
448431 } else if (auto OtherCtorE = dyn_cast<OtherConstructorDeclRefExpr>(E)) {
449432 if (!passReference (OtherCtorE->getDecl (), OtherCtorE->getType (),
@@ -478,7 +461,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
478461 }
479462
480463 // We already visited the children.
481- return doSkipChildren ( );
464+ return Action::SkipChildren (E );
482465
483466 } else if (auto *KPE = dyn_cast<KeyPathExpr>(E)) {
484467 for (auto &component : KPE->getComponents ()) {
@@ -522,7 +505,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
522505 return Action::Stop ();
523506
524507 // We already visited the children.
525- return doSkipChildren ( );
508+ return Action::SkipChildren (E );
526509 } else if (auto IOE = dyn_cast<InOutExpr>(E)) {
527510 llvm::SaveAndRestore<llvm::Optional<AccessKind>> C (this ->OpAccess ,
528511 AccessKind::ReadWrite);
@@ -531,7 +514,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
531514 return Action::Stop ();
532515
533516 // We already visited the children.
534- return doSkipChildren ( );
517+ return Action::SkipChildren (E );
535518 } else if (auto LE = dyn_cast<LoadExpr>(E)) {
536519 llvm::SaveAndRestore<llvm::Optional<AccessKind>> C (this ->OpAccess ,
537520 AccessKind::Read);
@@ -540,7 +523,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
540523 return Action::Stop ();
541524
542525 // We already visited the children.
543- return doSkipChildren ( );
526+ return Action::SkipChildren (E );
544527 } else if (auto AE = dyn_cast<AssignExpr>(E)) {
545528 {
546529 llvm::SaveAndRestore<llvm::Optional<AccessKind>> C (this ->OpAccess ,
@@ -554,7 +537,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
554537 return Action::Stop ();
555538
556539 // We already visited the children.
557- return doSkipChildren ( );
540+ return Action::SkipChildren (E );
558541 } else if (auto OEE = dyn_cast<OpenExistentialExpr>(E)) {
559542 // Record opaque value.
560543 OpaqueValueMap[OEE->getOpaqueValue ()] = OEE->getExistentialValue ();
@@ -565,7 +548,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
565548 if (!OEE->getSubExpr ()->walk (*this ))
566549 return Action::Stop ();
567550
568- return doSkipChildren ( );
551+ return Action::SkipChildren (E );
569552 } else if (auto MTEE = dyn_cast<MakeTemporarilyEscapableExpr>(E)) {
570553 // Manually walk to original arguments in order. We don't handle
571554 // OpaqueValueExpr here.
@@ -579,23 +562,23 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
579562 if (!callExpr->getFn ()->walk (*this ))
580563 return Action::Stop ();
581564
582- return doSkipChildren ( );
565+ return Action::SkipChildren (E );
583566 } else if (auto CUCE = dyn_cast<CollectionUpcastConversionExpr>(E)) {
584567 // Ignore conversion expressions. We don't handle OpaqueValueExpr here
585568 // because it's only in conversion expressions. Instead, just walk into
586569 // sub expression.
587570 if (!CUCE->getSubExpr ()->walk (*this ))
588571 return Action::Stop ();
589572
590- return doSkipChildren ( );
573+ return Action::SkipChildren (E );
591574 } else if (auto OVE = dyn_cast<OpaqueValueExpr>(E)) {
592575 // Walk into mapped value.
593576 auto value = OpaqueValueMap.find (OVE);
594577 if (value != OpaqueValueMap.end ()) {
595578 if (!value->second ->walk (*this ))
596579 return Action::Stop ();
597580
598- return doSkipChildren ( );
581+ return Action::SkipChildren (E );
599582 }
600583 } else if (auto DMRE = dyn_cast<DynamicMemberRefExpr>(E)) {
601584 // Visit in source order.
@@ -604,10 +587,11 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
604587 if (!passReference (DMRE->getMember ().getDecl (), DMRE->getType (),
605588 DMRE->getNameLoc (),
606589 ReferenceMetaData (SemaReferenceKind::DynamicMemberRef,
607- OpAccess)))
590+ OpAccess))) {
608591 return Action::Stop ();
592+ }
609593 // We already visited the children.
610- return doSkipChildren ( );
594+ return Action::SkipChildren (E );
611595 } else if (auto ME = dyn_cast<MacroExpansionExpr>(E)) {
612596 // Add a reference to the macro if this is a true macro expansion *expression*.
613597 // If this is a `MacroExpansionExpr` that expands a declaration macro, the
0 commit comments