@@ -213,7 +213,8 @@ enum class DescriptiveDeclKind : uint8_t {
213213 OpaqueResultType,
214214 OpaqueVarType,
215215 Macro,
216- MacroExpansion
216+ MacroExpansion,
217+ Using
217218};
218219
219220// / Describes which spelling was used in the source for the 'static' or 'class'
@@ -267,6 +268,16 @@ static_assert(uint8_t(SelfAccessKind::LastSelfAccessKind) <
267268 " Self Access Kind is too small to fit in SelfAccess kind bits. "
268269 " Please expand " );
269270
271+ enum class UsingSpecifier : uint8_t {
272+ MainActor,
273+ Nonisolated,
274+ LastSpecifier = Nonisolated,
275+ };
276+ enum : unsigned {
277+ NumUsingSpecifierBits =
278+ countBitsUsed (static_cast <unsigned >(UsingSpecifier::LastSpecifier))
279+ };
280+
270281// / Diagnostic printing of \c SelfAccessKind.
271282llvm::raw_ostream &operator <<(llvm::raw_ostream &OS, SelfAccessKind SAK);
272283
@@ -827,6 +838,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
827838 NumPathElements : 8
828839 );
829840
841+ SWIFT_INLINE_BITFIELD (UsingDecl, Decl, NumUsingSpecifierBits,
842+ Specifier : NumUsingSpecifierBits
843+ );
844+
830845 SWIFT_INLINE_BITFIELD (ExtensionDecl, Decl, 4 +1 ,
831846 // / An encoding of the default and maximum access level for this extension.
832847 // / The value 4 corresponds to AccessLevel::Public
@@ -9737,6 +9752,34 @@ class MacroExpansionDecl : public Decl, public FreestandingMacroExpansion {
97379752 }
97389753};
97399754
9755+ // / UsingDecl - This represents a single `using` declaration, e.g.:
9756+ // / using @MainActor
9757+ class UsingDecl : public Decl {
9758+ friend class Decl ;
9759+
9760+ private:
9761+ SourceLoc UsingLoc, SpecifierLoc;
9762+
9763+ UsingDecl (SourceLoc usingLoc, SourceLoc specifierLoc,
9764+ UsingSpecifier specifier, DeclContext *parent);
9765+
9766+ public:
9767+ UsingSpecifier getSpecifier () const {
9768+ return static_cast <UsingSpecifier>(Bits.UsingDecl .Specifier );
9769+ }
9770+
9771+ std::string getSpecifierName () const ;
9772+
9773+ SourceLoc getLocFromSource () const { return UsingLoc; }
9774+ SourceRange getSourceRange () const { return {UsingLoc, SpecifierLoc}; }
9775+
9776+ static UsingDecl *create (ASTContext &ctx, SourceLoc usingLoc,
9777+ SourceLoc specifierLoc, UsingSpecifier specifier,
9778+ DeclContext *parent);
9779+
9780+ static bool classof (const Decl *D) { return D->getKind () == DeclKind::Using; }
9781+ };
9782+
97409783inline void
97419784AbstractStorageDecl::overwriteSetterAccess (AccessLevel accessLevel) {
97429785 Accessors.setInt (accessLevel);
0 commit comments