@@ -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
@@ -830,6 +841,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
830841 NumPathElements : 8
831842 );
832843
844+ SWIFT_INLINE_BITFIELD (UsingDecl, Decl, NumUsingSpecifierBits,
845+ Specifier : NumUsingSpecifierBits
846+ );
847+
833848 SWIFT_INLINE_BITFIELD (ExtensionDecl, Decl, 4 +1 ,
834849 // / An encoding of the default and maximum access level for this extension.
835850 // / The value 4 corresponds to AccessLevel::Public
@@ -9738,6 +9753,34 @@ class MacroExpansionDecl : public Decl, public FreestandingMacroExpansion {
97389753 }
97399754};
97409755
9756+ // / UsingDecl - This represents a single `using` declaration, e.g.:
9757+ // / using @MainActor
9758+ class UsingDecl : public Decl {
9759+ friend class Decl ;
9760+
9761+ private:
9762+ SourceLoc UsingLoc, SpecifierLoc;
9763+
9764+ UsingDecl (SourceLoc usingLoc, SourceLoc specifierLoc,
9765+ UsingSpecifier specifier, DeclContext *parent);
9766+
9767+ public:
9768+ UsingSpecifier getSpecifier () const {
9769+ return static_cast <UsingSpecifier>(Bits.UsingDecl .Specifier );
9770+ }
9771+
9772+ std::string getSpecifierName () const ;
9773+
9774+ SourceLoc getLocFromSource () const { return UsingLoc; }
9775+ SourceRange getSourceRange () const { return {UsingLoc, SpecifierLoc}; }
9776+
9777+ static UsingDecl *create (ASTContext &ctx, SourceLoc usingLoc,
9778+ SourceLoc specifierLoc, UsingSpecifier specifier,
9779+ DeclContext *parent);
9780+
9781+ static bool classof (const Decl *D) { return D->getKind () == DeclKind::Using; }
9782+ };
9783+
97419784inline void
97429785AbstractStorageDecl::overwriteSetterAccess (AccessLevel accessLevel) {
97439786 Accessors.setInt (accessLevel);
0 commit comments