Skip to content

Commit 9598876

Browse files
committed
[Type checker] Pull the null check into swift::isSIMDOperator().
(cherry picked from commit 052d4c1)
1 parent f8eee49 commit 9598876

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/Sema/CSStep.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ bool DisjunctionStep::shouldStopAt(const DisjunctionChoice &choice) const {
491491
}
492492

493493
bool swift::isSIMDOperator(ValueDecl *value) {
494+
if (!value)
495+
return false;
496+
494497
auto func = dyn_cast<FuncDecl>(value);
495498
if (!func)
496499
return false;
@@ -556,10 +559,8 @@ bool DisjunctionStep::shortCircuitDisjunctionAt(
556559
// If we have an operator from the SIMDOperators module, and the prior
557560
// choice was not from the SIMDOperators module, we're done.
558561
if (currentChoice->getKind() == ConstraintKind::BindOverload &&
559-
currentChoice->getOverloadChoice().isDecl() &&
560562
isSIMDOperator(currentChoice->getOverloadChoice().getDecl()) &&
561563
lastSuccessfulChoice->getKind() == ConstraintKind::BindOverload &&
562-
lastSuccessfulChoice->getOverloadChoice().isDecl() &&
563564
!isSIMDOperator(lastSuccessfulChoice->getOverloadChoice().getDecl()) &&
564565
!ctx.LangOpts.SolverEnableOperatorDesignatedTypes) {
565566
return true;

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ static ArrayRef<OverloadChoice> partitionSIMDOperators(
14591459
// Check whether we have any SIMD operators.
14601460
bool foundSIMDOperator = false;
14611461
for (const auto &choice : choices) {
1462-
if (choice.isDecl() && isSIMDOperator(choice.getDecl())) {
1462+
if (isSIMDOperator(choice.getDecl())) {
14631463
foundSIMDOperator = true;
14641464
break;
14651465
}
@@ -1471,8 +1471,7 @@ static ArrayRef<OverloadChoice> partitionSIMDOperators(
14711471
scratch.assign(choices.begin(), choices.end());
14721472
std::stable_partition(scratch.begin(), scratch.end(),
14731473
[](const OverloadChoice &choice) {
1474-
return !choice.isDecl() ||
1475-
!isSIMDOperator(choice.getDecl());
1474+
return !isSIMDOperator(choice.getDecl());
14761475
});
14771476

14781477
return scratch;

0 commit comments

Comments
 (0)