|
23 | 23 | #include "swift/AST/AvailabilityRange.h" |
24 | 24 | #include "swift/AST/ConcreteDeclRef.h" |
25 | 25 | #include "swift/AST/DeclNameLoc.h" |
| 26 | +#include "swift/AST/DiagnosticGroups.h" |
26 | 27 | #include "swift/AST/Identifier.h" |
27 | 28 | #include "swift/AST/KnownProtocols.h" |
28 | 29 | #include "swift/AST/LifetimeDependence.h" |
@@ -3641,6 +3642,40 @@ class NonexhaustiveAttr : public DeclAttribute { |
3641 | 3642 | } |
3642 | 3643 | }; |
3643 | 3644 |
|
| 3645 | +class WarnAttr : public DeclAttribute { |
| 3646 | +public: |
| 3647 | + enum class Behavior : uint8_t { Error, Warning, Ignored }; |
| 3648 | + |
| 3649 | + WarnAttr(DiagGroupID DiagnosticGroupID, Behavior Behavior, |
| 3650 | + std::optional<StringRef> Reason, SourceLoc AtLoc, SourceRange Range, |
| 3651 | + bool Implicit) |
| 3652 | + : DeclAttribute(DeclAttrKind::Warn, AtLoc, Range, Implicit), |
| 3653 | + DiagnosticBehavior(Behavior), DiagnosticGroupID(DiagnosticGroupID), |
| 3654 | + Reason(Reason) {} |
| 3655 | + |
| 3656 | + WarnAttr(DiagGroupID DiagnosticGroupID, Behavior Behavior, bool Implicit) |
| 3657 | + : WarnAttr(DiagnosticGroupID, Behavior, std::nullopt, SourceLoc(), |
| 3658 | + SourceRange(), Implicit) {} |
| 3659 | + |
| 3660 | + Behavior DiagnosticBehavior; |
| 3661 | + DiagGroupID DiagnosticGroupID; |
| 3662 | + const std::optional<StringRef> Reason; |
| 3663 | + |
| 3664 | + static bool classof(const DeclAttribute *DA) { |
| 3665 | + return DA->getKind() == DeclAttrKind::Warn; |
| 3666 | + } |
| 3667 | + |
| 3668 | + WarnAttr *clone(ASTContext &ctx) const { |
| 3669 | + return new (ctx) WarnAttr(DiagnosticGroupID, DiagnosticBehavior, Reason, |
| 3670 | + AtLoc, Range, isImplicit()); |
| 3671 | + } |
| 3672 | + |
| 3673 | + bool isEquivalent(const WarnAttr *other, |
| 3674 | + Decl *attachedTo) const { |
| 3675 | + return Reason == other->Reason; |
| 3676 | + } |
| 3677 | +}; |
| 3678 | + |
3644 | 3679 |
|
3645 | 3680 | /// The kind of unary operator, if any. |
3646 | 3681 | enum class UnaryOperatorKind : uint8_t { None, Prefix, Postfix }; |
|
0 commit comments