@@ -204,11 +204,7 @@ class ValidateIfConfigCondition :
204204
205205 // Apply the operator with left-associativity by folding the first two
206206 // 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 );
212208
213209 // If we don't have the next operator, we're done.
214210 if (IsEnd)
@@ -527,9 +523,8 @@ class EvaluateIfConfigCondition :
527523
528524 bool visitBinaryExpr (BinaryExpr *E) {
529525 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 ());
533528 llvm_unreachable (" unsupported binary operator" );
534529 }
535530
@@ -557,9 +552,8 @@ class IsVersionIfConfigCondition :
557552
558553 bool visitBinaryExpr (BinaryExpr *E) {
559554 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 ());
563557 llvm_unreachable (" unsupported binary operator" );
564558 }
565559
@@ -592,9 +586,8 @@ static bool isPlatformConditionDisjunction(Expr *E, PlatformConditionKind Kind,
592586 ArrayRef<StringRef> Vals) {
593587 if (auto *Or = dyn_cast<BinaryExpr>(E)) {
594588 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));
598591 }
599592 } else if (auto *P = dyn_cast<ParenExpr>(E)) {
600593 return isPlatformConditionDisjunction (P->getSubExpr (), Kind, Vals);
@@ -655,11 +648,10 @@ static Expr *findAnyLikelySimulatorEnvironmentTest(Expr *Condition) {
655648
656649 if (auto *And = dyn_cast<BinaryExpr>(Condition)) {
657650 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 ()))) {
663655 return And;
664656 }
665657 }
0 commit comments