|
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/ExportKind.h" |
27 | 28 | #include "swift/AST/Identifier.h" |
28 | 29 | #include "swift/AST/KnownProtocols.h" |
@@ -3678,6 +3679,40 @@ class NonexhaustiveAttr : public DeclAttribute { |
3678 | 3679 | } |
3679 | 3680 | }; |
3680 | 3681 |
|
| 3682 | +class WarnAttr : public DeclAttribute { |
| 3683 | +public: |
| 3684 | + enum class Behavior : uint8_t { Error, Warning, Ignored }; |
| 3685 | + |
| 3686 | + WarnAttr(DiagGroupID DiagnosticGroupID, Behavior Behavior, |
| 3687 | + std::optional<StringRef> Reason, SourceLoc AtLoc, SourceRange Range, |
| 3688 | + bool Implicit) |
| 3689 | + : DeclAttribute(DeclAttrKind::Warn, AtLoc, Range, Implicit), |
| 3690 | + DiagnosticBehavior(Behavior), DiagnosticGroupID(DiagnosticGroupID), |
| 3691 | + Reason(Reason) {} |
| 3692 | + |
| 3693 | + WarnAttr(DiagGroupID DiagnosticGroupID, Behavior Behavior, bool Implicit) |
| 3694 | + : WarnAttr(DiagnosticGroupID, Behavior, std::nullopt, SourceLoc(), |
| 3695 | + SourceRange(), Implicit) {} |
| 3696 | + |
| 3697 | + Behavior DiagnosticBehavior; |
| 3698 | + DiagGroupID DiagnosticGroupID; |
| 3699 | + const std::optional<StringRef> Reason; |
| 3700 | + |
| 3701 | + static bool classof(const DeclAttribute *DA) { |
| 3702 | + return DA->getKind() == DeclAttrKind::Warn; |
| 3703 | + } |
| 3704 | + |
| 3705 | + WarnAttr *clone(ASTContext &ctx) const { |
| 3706 | + return new (ctx) WarnAttr(DiagnosticGroupID, DiagnosticBehavior, Reason, |
| 3707 | + AtLoc, Range, isImplicit()); |
| 3708 | + } |
| 3709 | + |
| 3710 | + bool isEquivalent(const WarnAttr *other, |
| 3711 | + Decl *attachedTo) const { |
| 3712 | + return Reason == other->Reason; |
| 3713 | + } |
| 3714 | +}; |
| 3715 | + |
3681 | 3716 |
|
3682 | 3717 | /// The kind of unary operator, if any. |
3683 | 3718 | enum class UnaryOperatorKind : uint8_t { None, Prefix, Postfix }; |
|
0 commit comments