@@ -347,23 +347,6 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
347
347
return Action::SkipNode (E);
348
348
}
349
349
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
-
367
350
if (auto *CtorRefE = dyn_cast<ConstructorRefCallExpr>(E))
368
351
CtorRefs.push_back (CtorRefE);
369
352
@@ -439,11 +422,11 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
439
422
if (!passReference (MRE->getMember ().getDecl (), MRE->getType (),
440
423
MRE->getNameLoc (),
441
424
ReferenceMetaData (SemaReferenceKind::DeclMemberRef,
442
- OpAccess)))
425
+ OpAccess))) {
443
426
return Action::Stop ();
444
-
427
+ }
445
428
// We already visited the children.
446
- return doSkipChildren ( );
429
+ return Action::SkipChildren (E );
447
430
448
431
} else if (auto OtherCtorE = dyn_cast<OtherConstructorDeclRefExpr>(E)) {
449
432
if (!passReference (OtherCtorE->getDecl (), OtherCtorE->getType (),
@@ -478,7 +461,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
478
461
}
479
462
480
463
// We already visited the children.
481
- return doSkipChildren ( );
464
+ return Action::SkipChildren (E );
482
465
483
466
} else if (auto *KPE = dyn_cast<KeyPathExpr>(E)) {
484
467
for (auto &component : KPE->getComponents ()) {
@@ -522,7 +505,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
522
505
return Action::Stop ();
523
506
524
507
// We already visited the children.
525
- return doSkipChildren ( );
508
+ return Action::SkipChildren (E );
526
509
} else if (auto IOE = dyn_cast<InOutExpr>(E)) {
527
510
llvm::SaveAndRestore<llvm::Optional<AccessKind>> C (this ->OpAccess ,
528
511
AccessKind::ReadWrite);
@@ -531,7 +514,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
531
514
return Action::Stop ();
532
515
533
516
// We already visited the children.
534
- return doSkipChildren ( );
517
+ return Action::SkipChildren (E );
535
518
} else if (auto LE = dyn_cast<LoadExpr>(E)) {
536
519
llvm::SaveAndRestore<llvm::Optional<AccessKind>> C (this ->OpAccess ,
537
520
AccessKind::Read);
@@ -540,7 +523,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
540
523
return Action::Stop ();
541
524
542
525
// We already visited the children.
543
- return doSkipChildren ( );
526
+ return Action::SkipChildren (E );
544
527
} else if (auto AE = dyn_cast<AssignExpr>(E)) {
545
528
{
546
529
llvm::SaveAndRestore<llvm::Optional<AccessKind>> C (this ->OpAccess ,
@@ -554,7 +537,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
554
537
return Action::Stop ();
555
538
556
539
// We already visited the children.
557
- return doSkipChildren ( );
540
+ return Action::SkipChildren (E );
558
541
} else if (auto OEE = dyn_cast<OpenExistentialExpr>(E)) {
559
542
// Record opaque value.
560
543
OpaqueValueMap[OEE->getOpaqueValue ()] = OEE->getExistentialValue ();
@@ -565,7 +548,7 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
565
548
if (!OEE->getSubExpr ()->walk (*this ))
566
549
return Action::Stop ();
567
550
568
- return doSkipChildren ( );
551
+ return Action::SkipChildren (E );
569
552
} else if (auto MTEE = dyn_cast<MakeTemporarilyEscapableExpr>(E)) {
570
553
// Manually walk to original arguments in order. We don't handle
571
554
// OpaqueValueExpr here.
@@ -579,23 +562,23 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
579
562
if (!callExpr->getFn ()->walk (*this ))
580
563
return Action::Stop ();
581
564
582
- return doSkipChildren ( );
565
+ return Action::SkipChildren (E );
583
566
} else if (auto CUCE = dyn_cast<CollectionUpcastConversionExpr>(E)) {
584
567
// Ignore conversion expressions. We don't handle OpaqueValueExpr here
585
568
// because it's only in conversion expressions. Instead, just walk into
586
569
// sub expression.
587
570
if (!CUCE->getSubExpr ()->walk (*this ))
588
571
return Action::Stop ();
589
572
590
- return doSkipChildren ( );
573
+ return Action::SkipChildren (E );
591
574
} else if (auto OVE = dyn_cast<OpaqueValueExpr>(E)) {
592
575
// Walk into mapped value.
593
576
auto value = OpaqueValueMap.find (OVE);
594
577
if (value != OpaqueValueMap.end ()) {
595
578
if (!value->second ->walk (*this ))
596
579
return Action::Stop ();
597
580
598
- return doSkipChildren ( );
581
+ return Action::SkipChildren (E );
599
582
}
600
583
} else if (auto DMRE = dyn_cast<DynamicMemberRefExpr>(E)) {
601
584
// Visit in source order.
@@ -604,10 +587,11 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
604
587
if (!passReference (DMRE->getMember ().getDecl (), DMRE->getType (),
605
588
DMRE->getNameLoc (),
606
589
ReferenceMetaData (SemaReferenceKind::DynamicMemberRef,
607
- OpAccess)))
590
+ OpAccess))) {
608
591
return Action::Stop ();
592
+ }
609
593
// We already visited the children.
610
- return doSkipChildren ( );
594
+ return Action::SkipChildren (E );
611
595
} else if (auto ME = dyn_cast<MacroExpansionExpr>(E)) {
612
596
// Add a reference to the macro if this is a true macro expansion *expression*.
613
597
// If this is a `MacroExpansionExpr` that expands a declaration macro, the
0 commit comments