Skip to content

Commit 54d891a

Browse files
committed
[NFC] Use DeclAttr.def flags for @abi checking
Information about this behavior is needed in other parts of the compiler, so let’s put it somewhere where we can get at it. The only test changes in this commit are to move comments out of the decl checker and into the test, since there is no longer anywhere else to put them.
1 parent 0bb329a commit 54d891a

File tree

5 files changed

+347
-527
lines changed

5 files changed

+347
-527
lines changed

include/swift/AST/Attr.h

+35
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,41 @@ class DeclAttribute : public AttributeBase {
364364

365365
/// The opposite of ABIBreakingToRemove
366366
ABIStableToRemove = 1ull << 15,
367+
368+
/// Attribute should not be used in an \c \@abi attribute. Use for
369+
/// attributes which cannot affect mangled names, even indirectly, and
370+
/// which either don't affect ABI or where ABI-only declarations get their
371+
/// behavior from their API counterpart.
372+
ForbiddenInABIAttr = 1ull << 16,
373+
374+
/// Attribute can be used without restrictions in an \c \@abi attribute.
375+
/// Use for attributes which affect mangled names but otherwise don't alter
376+
/// the ABI, or ones where the \c ABIDeclChecker manually implements
377+
/// special checking logic (e.g. because several different attributes
378+
/// contribute to the same aspect of ABI in some complicated way).
379+
UnconstrainedInABIAttr = 1ull << 17,
380+
381+
/// Attribute can be used in an \c \@abi attribute, but must match
382+
/// equivalent on API decl. Use for attributes which affect both mangled
383+
/// names and other parts of the ABI such that the declaration can only be
384+
/// valid if they match.
385+
EquivalentInABIAttr = 1ull << 18,
386+
387+
/// Attribute can be used in an \c \@abi attribute, but must match
388+
/// equivalent on API decl; if omitted, API decl's attribute will be
389+
/// cloned. Use where you would want to use \c EquivalentInABIAttr but
390+
/// repeating the attribute is judged too burdensome.
391+
InferredInABIAttr = 1ull << 19,
392+
393+
/// Use for attributes which are \em only valid on declarations that cannot
394+
/// have an \c @abi attribute, such as \c ImportDecl .
395+
UnreachableInABIAttr = 1ull << 20,
396+
};
397+
398+
enum : uint64_t {
399+
InABIAttrMask = ForbiddenInABIAttr | UnconstrainedInABIAttr
400+
| EquivalentInABIAttr | InferredInABIAttr
401+
| UnreachableInABIAttr
367402
};
368403

369404
LLVM_READNONE

0 commit comments

Comments
 (0)