@@ -189,6 +189,7 @@ DescriptiveDeclKind Decl::getDescriptiveKind() const {
189
189
TRIVIAL_KIND (MissingMember);
190
190
TRIVIAL_KIND (Macro);
191
191
TRIVIAL_KIND (MacroExpansion);
192
+ TRIVIAL_KIND (Using);
192
193
193
194
case DeclKind::TypeAlias:
194
195
return cast<TypeAliasDecl>(this )->getGenericParams ()
@@ -400,6 +401,7 @@ StringRef Decl::getDescriptiveKindName(DescriptiveDeclKind K) {
400
401
ENTRY (OpaqueVarType, " type" );
401
402
ENTRY (Macro, " macro" );
402
403
ENTRY (MacroExpansion, " pound literal" );
404
+ ENTRY (Using, " using" );
403
405
}
404
406
#undef ENTRY
405
407
llvm_unreachable (" bad DescriptiveDeclKind" );
@@ -1711,6 +1713,7 @@ ImportKind ImportDecl::getBestImportKind(const ValueDecl *VD) {
1711
1713
case DeclKind::Missing:
1712
1714
case DeclKind::MissingMember:
1713
1715
case DeclKind::MacroExpansion:
1716
+ case DeclKind::Using:
1714
1717
llvm_unreachable (" not a ValueDecl" );
1715
1718
1716
1719
case DeclKind::AssociatedType:
@@ -1838,6 +1841,30 @@ bool ImportDecl::isAccessLevelImplicit() const {
1838
1841
return true ;
1839
1842
}
1840
1843
1844
+ UsingDecl::UsingDecl (SourceLoc usingLoc, SourceLoc specifierLoc,
1845
+ UsingSpecifier specifier, DeclContext *parent)
1846
+ : Decl(DeclKind::Using, parent), UsingLoc(usingLoc),
1847
+ SpecifierLoc(specifierLoc) {
1848
+ Bits.UsingDecl .Specifier = static_cast <unsigned >(specifier);
1849
+ assert (getSpecifier () == specifier &&
1850
+ " not enough bits in UsingDecl flags for specifier" );
1851
+ }
1852
+
1853
+ std::string UsingDecl::getSpecifierName () const {
1854
+ switch (getSpecifier ()) {
1855
+ case UsingSpecifier::MainActor:
1856
+ return " @MainActor" ;
1857
+ case UsingSpecifier::nonisolated:
1858
+ return " nonisolated" ;
1859
+ }
1860
+ }
1861
+
1862
+ UsingDecl *UsingDecl::create (ASTContext &ctx, SourceLoc usingLoc,
1863
+ SourceLoc specifierLoc, UsingSpecifier specifier,
1864
+ DeclContext *parent) {
1865
+ return new (ctx) UsingDecl (usingLoc, specifierLoc, specifier, parent);
1866
+ }
1867
+
1841
1868
void NominalTypeDecl::setConformanceLoader (LazyMemberLoader *lazyLoader,
1842
1869
uint64_t contextData) {
1843
1870
assert (!Bits.NominalTypeDecl .HasLazyConformances &&
@@ -3652,6 +3679,7 @@ bool ValueDecl::isInstanceMember() const {
3652
3679
case DeclKind::Missing:
3653
3680
case DeclKind::MissingMember:
3654
3681
case DeclKind::MacroExpansion:
3682
+ case DeclKind::Using:
3655
3683
llvm_unreachable (" Not a ValueDecl" );
3656
3684
3657
3685
case DeclKind::Class:
@@ -4765,6 +4793,7 @@ SourceLoc Decl::getAttributeInsertionLoc(bool forModifier) const {
4765
4793
case DeclKind::MissingMember:
4766
4794
case DeclKind::MacroExpansion:
4767
4795
case DeclKind::BuiltinTuple:
4796
+ case DeclKind::Using:
4768
4797
// These don't take attributes.
4769
4798
return SourceLoc ();
4770
4799
0 commit comments