Skip to content

Commit b0f7aef

Browse files
committed
[ConstraintSystem] NFC: Warn if result of generate* is unused
Not checking success of constraint generation could lead to crashes e.g. when follow-up code accesses something that hasn't been processed due to error.
1 parent 565ed69 commit b0f7aef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,6 +4587,7 @@ class ConstraintSystem {
45874587
/// Generate constraints for the given solution target.
45884588
///
45894589
/// \returns true if an error occurred, false otherwise.
4590+
LLVM_NODISCARD
45904591
bool generateConstraints(SolutionApplicationTarget &target,
45914592
FreeTypeVariableBinding allowFreeTypeVariables);
45924593

@@ -4595,18 +4596,21 @@ class ConstraintSystem {
45954596
/// \param closure the closure expression
45964597
///
45974598
/// \returns \c true if constraint generation failed, \c false otherwise
4599+
LLVM_NODISCARD
45984600
bool generateConstraints(ClosureExpr *closure);
45994601

46004602
/// Generate constraints for the given (unchecked) expression.
46014603
///
46024604
/// \returns a possibly-sanitized expression, or null if an error occurred.
4605+
LLVM_NODISCARD
46034606
Expr *generateConstraints(Expr *E, DeclContext *dc,
46044607
bool isInputExpression = true);
46054608

46064609
/// Generate constraints for binding the given pattern to the
46074610
/// value of the given expression.
46084611
///
46094612
/// \returns a possibly-sanitized initializer, or null if an error occurred.
4613+
LLVM_NODISCARD
46104614
Type generateConstraints(Pattern *P, ConstraintLocatorBuilder locator,
46114615
bool bindPatternVarsOneWay,
46124616
PatternBindingDecl *patternBinding,
@@ -4616,6 +4620,7 @@ class ConstraintSystem {
46164620
///
46174621
/// \returns true if there was an error in constraint generation, false
46184622
/// if generation succeeded.
4623+
LLVM_NODISCARD
46194624
bool generateConstraints(StmtCondition condition, DeclContext *dc);
46204625

46214626
/// Generate constraints for a case statement.
@@ -4625,6 +4630,7 @@ class ConstraintSystem {
46254630
///
46264631
/// \returns true if there was an error in constraint generation, false
46274632
/// if generation succeeded.
4633+
LLVM_NODISCARD
46284634
bool generateConstraints(CaseStmt *caseStmt, DeclContext *dc,
46294635
Type subjectType, ConstraintLocator *locator);
46304636

@@ -4668,6 +4674,7 @@ class ConstraintSystem {
46684674
/// \param propertyType The type of the wrapped property.
46694675
///
46704676
/// \returns true if there is an error.
4677+
LLVM_NODISCARD
46714678
bool generateWrappedPropertyTypeConstraints(VarDecl *wrappedVar,
46724679
Type initializerType,
46734680
Type propertyType);

0 commit comments

Comments
 (0)