From 052d4c196cf0e5abd4e85ee6cf482a99fc2eb223 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Tue, 11 Dec 2018 16:39:10 -0800 Subject: [PATCH] [Type checker] Pull the null check into swift::isSIMDOperator(). --- lib/Sema/CSStep.cpp | 5 +++-- lib/Sema/ConstraintSystem.cpp | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Sema/CSStep.cpp b/lib/Sema/CSStep.cpp index 136f54bbb6f..75b03ea9667 100644 --- a/lib/Sema/CSStep.cpp +++ b/lib/Sema/CSStep.cpp @@ -491,6 +491,9 @@ bool DisjunctionStep::shouldStopAt(const DisjunctionChoice &choice) const { } bool swift::isSIMDOperator(ValueDecl *value) { + if (!value) + return false; + auto func = dyn_cast(value); if (!func) return false; @@ -556,10 +559,8 @@ bool DisjunctionStep::shortCircuitDisjunctionAt( // If we have an operator from the SIMDOperators module, and the prior // choice was not from the SIMDOperators module, we're done. if (currentChoice->getKind() == ConstraintKind::BindOverload && - currentChoice->getOverloadChoice().isDecl() && isSIMDOperator(currentChoice->getOverloadChoice().getDecl()) && lastSuccessfulChoice->getKind() == ConstraintKind::BindOverload && - lastSuccessfulChoice->getOverloadChoice().isDecl() && !isSIMDOperator(lastSuccessfulChoice->getOverloadChoice().getDecl()) && !ctx.LangOpts.SolverEnableOperatorDesignatedTypes) { return true; diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index ee28260f877..f4b0d01c454 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -1473,7 +1473,7 @@ static ArrayRef partitionSIMDOperators( // Check whether we have any SIMD operators. bool foundSIMDOperator = false; for (const auto &choice : choices) { - if (choice.isDecl() && isSIMDOperator(choice.getDecl())) { + if (isSIMDOperator(choice.getDecl())) { foundSIMDOperator = true; break; } @@ -1485,8 +1485,7 @@ static ArrayRef partitionSIMDOperators( scratch.assign(choices.begin(), choices.end()); std::stable_partition(scratch.begin(), scratch.end(), [](const OverloadChoice &choice) { - return !choice.isDecl() || - !isSIMDOperator(choice.getDecl()); + return !isSIMDOperator(choice.getDecl()); }); return scratch;