Skip to content

Commit 54fe130

Browse files
committed
replace LLVM_NODISCARD -> [[nodiscard]]
This is possible because we are now compiling with the C++17 standard.
1 parent 0554f47 commit 54fe130

17 files changed

+147
-164
lines changed

include/swift/AST/ExtInfo.h

+22-22
Original file line numberDiff line numberDiff line change
@@ -412,46 +412,46 @@ class ASTExtInfoBuilder {
412412

413413
// Note that we don't have setters. That is by design, use
414414
// the following with methods instead of mutating these objects.
415-
LLVM_NODISCARD
415+
[[nodiscard]]
416416
ASTExtInfoBuilder withRepresentation(Representation rep) const {
417417
return ASTExtInfoBuilder((bits & ~RepresentationMask) | (unsigned)rep,
418418
shouldStoreClangType(rep) ? clangTypeInfo
419419
: ClangTypeInfo(),
420420
globalActor);
421421
}
422-
LLVM_NODISCARD
422+
[[nodiscard]]
423423
ASTExtInfoBuilder withNoEscape(bool noEscape = true) const {
424424
return ASTExtInfoBuilder(noEscape ? (bits | NoEscapeMask)
425425
: (bits & ~NoEscapeMask),
426426
clangTypeInfo, globalActor);
427427
}
428-
LLVM_NODISCARD
428+
[[nodiscard]]
429429
ASTExtInfoBuilder withConcurrent(bool concurrent = true) const {
430430
return ASTExtInfoBuilder(concurrent ? (bits | SendableMask)
431431
: (bits & ~SendableMask),
432432
clangTypeInfo, globalActor);
433433
}
434-
LLVM_NODISCARD
434+
[[nodiscard]]
435435
ASTExtInfoBuilder withAsync(bool async = true) const {
436436
return ASTExtInfoBuilder(async ? (bits | AsyncMask)
437437
: (bits & ~AsyncMask),
438438
clangTypeInfo, globalActor);
439439
}
440-
LLVM_NODISCARD
440+
[[nodiscard]]
441441
ASTExtInfoBuilder withThrows(bool throws = true) const {
442442
return ASTExtInfoBuilder(
443443
throws ? (bits | ThrowsMask) : (bits & ~ThrowsMask), clangTypeInfo,
444444
globalActor);
445445
}
446-
LLVM_NODISCARD
446+
[[nodiscard]]
447447
ASTExtInfoBuilder
448448
withDifferentiabilityKind(DifferentiabilityKind differentiability) const {
449449
return ASTExtInfoBuilder(
450450
(bits & ~DifferentiabilityMask) |
451451
((unsigned)differentiability << DifferentiabilityMaskOffset),
452452
clangTypeInfo, globalActor);
453453
}
454-
LLVM_NODISCARD
454+
[[nodiscard]]
455455
ASTExtInfoBuilder withClangFunctionType(const clang::Type *type) const {
456456
return ASTExtInfoBuilder(bits, ClangTypeInfo(type), globalActor);
457457
}
@@ -461,7 +461,7 @@ class ASTExtInfoBuilder {
461461
/// SIL type lowering transiently generates AST function types with SIL
462462
/// representations. However, they shouldn't persist in the AST, and
463463
/// don't need to be parsed, printed, or serialized.
464-
LLVM_NODISCARD
464+
[[nodiscard]]
465465
ASTExtInfoBuilder
466466
withSILRepresentation(SILFunctionTypeRepresentation rep) const {
467467
return ASTExtInfoBuilder((bits & ~RepresentationMask) | (unsigned)rep,
@@ -470,7 +470,7 @@ class ASTExtInfoBuilder {
470470
globalActor);
471471
}
472472

473-
LLVM_NODISCARD
473+
[[nodiscard]]
474474
ASTExtInfoBuilder withGlobalActor(Type globalActor) const {
475475
return ASTExtInfoBuilder(bits, clangTypeInfo, globalActor);
476476
}
@@ -555,44 +555,44 @@ class ASTExtInfo {
555555
/// Helper method for changing the representation.
556556
///
557557
/// Prefer using \c ASTExtInfoBuilder::withRepresentation for chaining.
558-
LLVM_NODISCARD
558+
[[nodiscard]]
559559
ASTExtInfo withRepresentation(ASTExtInfoBuilder::Representation rep) const {
560560
return builder.withRepresentation(rep).build();
561561
}
562562

563563
/// Helper method for changing only the noEscape field.
564564
///
565565
/// Prefer using \c ASTExtInfoBuilder::withNoEscape for chaining.
566-
LLVM_NODISCARD
566+
[[nodiscard]]
567567
ASTExtInfo withNoEscape(bool noEscape = true) const {
568568
return builder.withNoEscape(noEscape).build();
569569
}
570570

571571
/// Helper method for changing only the concurrent field.
572572
///
573573
/// Prefer using \c ASTExtInfoBuilder::withConcurrent for chaining.
574-
LLVM_NODISCARD
574+
[[nodiscard]]
575575
ASTExtInfo withConcurrent(bool concurrent = true) const {
576576
return builder.withConcurrent(concurrent).build();
577577
}
578578

579579
/// Helper method for changing only the throws field.
580580
///
581581
/// Prefer using \c ASTExtInfoBuilder::withThrows for chaining.
582-
LLVM_NODISCARD
582+
[[nodiscard]]
583583
ASTExtInfo withThrows(bool throws = true) const {
584584
return builder.withThrows(throws).build();
585585
}
586586

587587
/// Helper method for changing only the async field.
588588
///
589589
/// Prefer using \c ASTExtInfoBuilder::withAsync for chaining.
590-
LLVM_NODISCARD
590+
[[nodiscard]]
591591
ASTExtInfo withAsync(bool async = true) const {
592592
return builder.withAsync(async).build();
593593
}
594594

595-
LLVM_NODISCARD
595+
[[nodiscard]]
596596
ASTExtInfo withGlobalActor(Type globalActor) const {
597597
return builder.withGlobalActor(globalActor).build();
598598
}
@@ -785,44 +785,44 @@ class SILExtInfoBuilder {
785785

786786
// Note that we don't have setters. That is by design, use
787787
// the following with methods instead of mutating these objects.
788-
LLVM_NODISCARD
788+
[[nodiscard]]
789789
SILExtInfoBuilder withRepresentation(Representation rep) const {
790790
return SILExtInfoBuilder((bits & ~RepresentationMask) | (unsigned)rep,
791791
shouldStoreClangType(rep) ? clangTypeInfo
792792
: ClangTypeInfo());
793793
}
794-
LLVM_NODISCARD
794+
[[nodiscard]]
795795
SILExtInfoBuilder withIsPseudogeneric(bool isPseudogeneric = true) const {
796796
return SILExtInfoBuilder(isPseudogeneric ? (bits | PseudogenericMask)
797797
: (bits & ~PseudogenericMask),
798798
clangTypeInfo);
799799
}
800-
LLVM_NODISCARD
800+
[[nodiscard]]
801801
SILExtInfoBuilder withNoEscape(bool noEscape = true) const {
802802
return SILExtInfoBuilder(noEscape ? (bits | NoEscapeMask)
803803
: (bits & ~NoEscapeMask),
804804
clangTypeInfo);
805805
}
806-
LLVM_NODISCARD
806+
[[nodiscard]]
807807
SILExtInfoBuilder withConcurrent(bool isSendable = true) const {
808808
return SILExtInfoBuilder(isSendable ? (bits | SendableMask)
809809
: (bits & ~SendableMask),
810810
clangTypeInfo);
811811
}
812-
LLVM_NODISCARD
812+
[[nodiscard]]
813813
SILExtInfoBuilder withAsync(bool isAsync = true) const {
814814
return SILExtInfoBuilder(isAsync ? (bits | AsyncMask) : (bits & ~AsyncMask),
815815
clangTypeInfo);
816816
}
817-
LLVM_NODISCARD
817+
[[nodiscard]]
818818
SILExtInfoBuilder
819819
withDifferentiabilityKind(DifferentiabilityKind differentiability) const {
820820
return SILExtInfoBuilder(
821821
(bits & ~DifferentiabilityMask) |
822822
((unsigned)differentiability << DifferentiabilityMaskOffset),
823823
clangTypeInfo);
824824
}
825-
LLVM_NODISCARD
825+
[[nodiscard]]
826826
SILExtInfoBuilder withClangFunctionType(const clang::Type *type) const {
827827
return SILExtInfoBuilder(bits, ClangTypeInfo(type).getCanonical());
828828
}

include/swift/Demangling/Demangle.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ enum class OperatorKind {
526526
};
527527

528528
/// A mangling error, which consists of an error code and a Node pointer
529-
struct LLVM_NODISCARD ManglingError {
529+
struct [[nodiscard]] ManglingError {
530530
enum Code {
531531
Success = 0,
532532
AssertionFailed,
@@ -568,7 +568,7 @@ struct LLVM_NODISCARD ManglingError {
568568

569569
/// Used as a return type for mangling functions that may fail
570570
template <typename T>
571-
class LLVM_NODISCARD ManglingErrorOr {
571+
class [[nodiscard]] ManglingErrorOr {
572572
private:
573573
ManglingError err_;
574574
T value_;

include/swift/Sema/ConstraintSystem.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -5046,7 +5046,7 @@ class ConstraintSystem {
50465046
/// Generate constraints for the given solution target.
50475047
///
50485048
/// \returns true if an error occurred, false otherwise.
5049-
LLVM_NODISCARD
5049+
[[nodiscard]]
50505050
bool generateConstraints(SolutionApplicationTarget &target,
50515051
FreeTypeVariableBinding allowFreeTypeVariables);
50525052

@@ -5055,7 +5055,7 @@ class ConstraintSystem {
50555055
/// \param closure the closure expression
50565056
///
50575057
/// \returns \c true if constraint generation failed, \c false otherwise
5058-
LLVM_NODISCARD
5058+
[[nodiscard]]
50595059
bool generateConstraints(ClosureExpr *closure);
50605060

50615061
/// Generate constraints for the body of the given function.
@@ -5065,21 +5065,21 @@ class ConstraintSystem {
50655065
/// used for constraint generation.
50665066
///
50675067
/// \returns \c true if constraint generation failed, \c false otherwise
5068-
LLVM_NODISCARD
5068+
[[nodiscard]]
50695069
bool generateConstraints(AnyFunctionRef fn, BraceStmt *body);
50705070

50715071
/// Generate constraints for the given (unchecked) expression.
50725072
///
50735073
/// \returns a possibly-sanitized expression, or null if an error occurred.
5074-
LLVM_NODISCARD
5074+
[[nodiscard]]
50755075
Expr *generateConstraints(Expr *E, DeclContext *dc,
50765076
bool isInputExpression = true);
50775077

50785078
/// Generate constraints for binding the given pattern to the
50795079
/// value of the given expression.
50805080
///
50815081
/// \returns a possibly-sanitized initializer, or null if an error occurred.
5082-
LLVM_NODISCARD
5082+
[[nodiscard]]
50835083
Type generateConstraints(Pattern *P, ConstraintLocatorBuilder locator,
50845084
bool bindPatternVarsOneWay,
50855085
PatternBindingDecl *patternBinding,
@@ -5089,7 +5089,7 @@ class ConstraintSystem {
50895089
///
50905090
/// \returns true if there was an error in constraint generation, false
50915091
/// if generation succeeded.
5092-
LLVM_NODISCARD
5092+
[[nodiscard]]
50935093
bool generateConstraints(StmtCondition condition, DeclContext *dc);
50945094

50955095
/// Generate constraints for a case statement.
@@ -5099,7 +5099,7 @@ class ConstraintSystem {
50995099
///
51005100
/// \returns true if there was an error in constraint generation, false
51015101
/// if generation succeeded.
5102-
LLVM_NODISCARD
5102+
[[nodiscard]]
51035103
bool generateConstraints(CaseStmt *caseStmt, DeclContext *dc,
51045104
Type subjectType, ConstraintLocator *locator);
51055105

@@ -5143,7 +5143,7 @@ class ConstraintSystem {
51435143
/// \param propertyType The type of the wrapped property.
51445144
///
51455145
/// \returns true if there is an error.
5146-
LLVM_NODISCARD
5146+
[[nodiscard]]
51475147
bool generateWrappedPropertyTypeConstraints(VarDecl *wrappedVar,
51485148
Type initializerType,
51495149
Type propertyType);

0 commit comments

Comments
 (0)