@@ -204,11 +204,7 @@ class ValidateIfConfigCondition :
204
204
205
205
// Apply the operator with left-associativity by folding the first two
206
206
// operands.
207
- TupleExpr *Arg = TupleExpr::create (Ctx, SourceLoc (), { LHS, RHS },
208
- { }, { }, SourceLoc (),
209
- /* HasTrailingClosure=*/ false ,
210
- /* Implicit=*/ true );
211
- LHS = new (Ctx) BinaryExpr (Op, Arg, /* implicit*/ false );
207
+ LHS = BinaryExpr::create (Ctx, LHS, Op, RHS, /* implicit*/ false );
212
208
213
209
// If we don't have the next operator, we're done.
214
210
if (IsEnd)
@@ -527,9 +523,8 @@ class EvaluateIfConfigCondition :
527
523
528
524
bool visitBinaryExpr (BinaryExpr *E) {
529
525
auto OpName = getDeclRefStr (E->getFn ());
530
- auto Args = E->getArg ()->getElements ();
531
- if (OpName == " ||" ) return visit (Args[0 ]) || visit (Args[1 ]);
532
- if (OpName == " &&" ) return visit (Args[0 ]) && visit (Args[1 ]);
526
+ if (OpName == " ||" ) return visit (E->getLHS ()) || visit (E->getRHS ());
527
+ if (OpName == " &&" ) return visit (E->getLHS ()) && visit (E->getRHS ());
533
528
llvm_unreachable (" unsupported binary operator" );
534
529
}
535
530
@@ -557,9 +552,8 @@ class IsVersionIfConfigCondition :
557
552
558
553
bool visitBinaryExpr (BinaryExpr *E) {
559
554
auto OpName = getDeclRefStr (E->getFn ());
560
- auto Args = E->getArg ()->getElements ();
561
- if (OpName == " ||" ) return visit (Args[0 ]) && visit (Args[1 ]);
562
- if (OpName == " &&" ) return visit (Args[0 ]) || visit (Args[1 ]);
555
+ if (OpName == " ||" ) return visit (E->getLHS ()) && visit (E->getRHS ());
556
+ if (OpName == " &&" ) return visit (E->getLHS ()) || visit (E->getRHS ());
563
557
llvm_unreachable (" unsupported binary operator" );
564
558
}
565
559
@@ -592,9 +586,8 @@ static bool isPlatformConditionDisjunction(Expr *E, PlatformConditionKind Kind,
592
586
ArrayRef<StringRef> Vals) {
593
587
if (auto *Or = dyn_cast<BinaryExpr>(E)) {
594
588
if (getDeclRefStr (Or->getFn ()) == " ||" ) {
595
- auto Args = Or->getArg ()->getElements ();
596
- return (isPlatformConditionDisjunction (Args[0 ], Kind, Vals) &&
597
- isPlatformConditionDisjunction (Args[1 ], Kind, Vals));
589
+ return (isPlatformConditionDisjunction (Or->getLHS (), Kind, Vals) &&
590
+ isPlatformConditionDisjunction (Or->getRHS (), Kind, Vals));
598
591
}
599
592
} else if (auto *P = dyn_cast<ParenExpr>(E)) {
600
593
return isPlatformConditionDisjunction (P->getSubExpr (), Kind, Vals);
@@ -655,11 +648,10 @@ static Expr *findAnyLikelySimulatorEnvironmentTest(Expr *Condition) {
655
648
656
649
if (auto *And = dyn_cast<BinaryExpr>(Condition)) {
657
650
if (getDeclRefStr (And->getFn ()) == " &&" ) {
658
- auto Args = And->getArg ()->getElements ();
659
- if ((isSimulatorPlatformOSTest (Args[0 ]) &&
660
- isSimulatorPlatformArchTest (Args[1 ])) ||
661
- (isSimulatorPlatformOSTest (Args[1 ]) &&
662
- isSimulatorPlatformArchTest (Args[0 ]))) {
651
+ if ((isSimulatorPlatformOSTest (And->getLHS ()) &&
652
+ isSimulatorPlatformArchTest (And->getRHS ())) ||
653
+ (isSimulatorPlatformOSTest (And->getRHS ()) &&
654
+ isSimulatorPlatformArchTest (And->getLHS ()))) {
663
655
return And;
664
656
}
665
657
}
0 commit comments