@@ -244,6 +244,10 @@ class DeclAttribute : public AttributeBase {
244
244
SWIFT_INLINE_BITFIELD (LifetimeAttr, DeclAttribute, 1 ,
245
245
isUnderscored : 1
246
246
);
247
+
248
+ SWIFT_INLINE_BITFIELD (NonexhaustiveAttr, DeclAttribute, NumNonexhaustiveModeBits,
249
+ mode : NumNonexhaustiveModeBits
250
+ );
247
251
} Bits;
248
252
// clang-format on
249
253
@@ -3334,6 +3338,35 @@ class ABIAttr : public DeclAttribute {
3334
3338
}
3335
3339
};
3336
3340
3341
+ // / Defines a @nonexhaustive attribute.
3342
+ class NonexhaustiveAttr : public DeclAttribute {
3343
+ public:
3344
+ NonexhaustiveAttr (SourceLoc atLoc, SourceRange range, NonexhaustiveMode mode,
3345
+ bool implicit = false )
3346
+ : DeclAttribute(DeclAttrKind::Nonexhaustive, atLoc, range, implicit) {
3347
+ Bits.NonexhaustiveAttr .mode = unsigned (mode);
3348
+ }
3349
+
3350
+ NonexhaustiveAttr (NonexhaustiveMode mode)
3351
+ : NonexhaustiveAttr(SourceLoc(), SourceRange(), mode) {}
3352
+
3353
+ NonexhaustiveMode getMode () const {
3354
+ return NonexhaustiveMode (Bits.NonexhaustiveAttr .mode );
3355
+ }
3356
+
3357
+ static bool classof (const DeclAttribute *DA) {
3358
+ return DA->getKind () == DeclAttrKind::Nonexhaustive;
3359
+ }
3360
+
3361
+ NonexhaustiveAttr *clone (ASTContext &ctx) const {
3362
+ return new (ctx) NonexhaustiveAttr (AtLoc, Range, getMode (), isImplicit ());
3363
+ }
3364
+
3365
+ bool isEquivalent (const NonexhaustiveAttr *other, Decl *attachedTo) const {
3366
+ return getMode () == other->getMode ();
3367
+ }
3368
+ };
3369
+
3337
3370
// / Attributes that may be applied to declarations.
3338
3371
class DeclAttributes {
3339
3372
// / Linked list of declaration attributes.
0 commit comments