@@ -213,7 +213,8 @@ enum class DescriptiveDeclKind : uint8_t {
213
213
OpaqueResultType,
214
214
OpaqueVarType,
215
215
Macro,
216
- MacroExpansion
216
+ MacroExpansion,
217
+ Using
217
218
};
218
219
219
220
// / Describes which spelling was used in the source for the 'static' or 'class'
@@ -267,6 +268,16 @@ static_assert(uint8_t(SelfAccessKind::LastSelfAccessKind) <
267
268
" Self Access Kind is too small to fit in SelfAccess kind bits. "
268
269
" Please expand " );
269
270
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
+
270
281
// / Diagnostic printing of \c SelfAccessKind.
271
282
llvm::raw_ostream &operator <<(llvm::raw_ostream &OS, SelfAccessKind SAK);
272
283
@@ -827,6 +838,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
827
838
NumPathElements : 8
828
839
);
829
840
841
+ SWIFT_INLINE_BITFIELD (UsingDecl, Decl, NumUsingSpecifierBits,
842
+ Specifier : NumUsingSpecifierBits
843
+ );
844
+
830
845
SWIFT_INLINE_BITFIELD (ExtensionDecl, Decl, 4 +1 ,
831
846
// / An encoding of the default and maximum access level for this extension.
832
847
// / The value 4 corresponds to AccessLevel::Public
@@ -9737,6 +9752,34 @@ class MacroExpansionDecl : public Decl, public FreestandingMacroExpansion {
9737
9752
}
9738
9753
};
9739
9754
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
+
9740
9783
inline void
9741
9784
AbstractStorageDecl::overwriteSetterAccess (AccessLevel accessLevel) {
9742
9785
Accessors.setInt (accessLevel);
0 commit comments