@@ -1113,7 +1113,8 @@ ParsedDeclAttrFilter::operator()(const DeclAttribute *Attr) const {
11131113 return Attr;
11141114}
11151115
1116- static void printAvailableAttr (const AvailableAttr *Attr, ASTPrinter &Printer,
1116+ static void printAvailableAttr (const Decl *D, const AvailableAttr *Attr,
1117+ ASTPrinter &Printer,
11171118 const PrintOptions &Options) {
11181119 if (Attr->isLanguageVersionSpecific ())
11191120 Printer << " swift" ;
@@ -1138,17 +1139,19 @@ static void printAvailableAttr(const AvailableAttr *Attr, ASTPrinter &Printer,
11381139
11391140 if (!Attr->Rename .empty ()) {
11401141 Printer << " , renamed: \" " << Attr->Rename << " \" " ;
1141- } else if (Attr->RenameDecl ) {
1142- Printer << " , renamed: \" " ;
1143- if (auto *Accessor = dyn_cast<AccessorDecl>(Attr->RenameDecl )) {
1144- SmallString<32 > Name;
1145- llvm::raw_svector_ostream OS (Name);
1146- Accessor->printUserFacingName (OS);
1147- Printer << Name.str ();
1148- } else {
1149- Printer << Attr->RenameDecl ->getName ();
1142+ } else if (auto *VD = dyn_cast<ValueDecl>(D)) {
1143+ if (auto *renamedDecl = VD->getRenamedDecl (Attr)) {
1144+ Printer << " , renamed: \" " ;
1145+ if (auto *Accessor = dyn_cast<AccessorDecl>(renamedDecl)) {
1146+ SmallString<32 > Name;
1147+ llvm::raw_svector_ostream OS (Name);
1148+ Accessor->printUserFacingName (OS);
1149+ Printer << Name.str ();
1150+ } else {
1151+ Printer << renamedDecl->getName ();
1152+ }
1153+ Printer << " \" " ;
11501154 }
1151- Printer << " \" " ;
11521155 }
11531156
11541157 // If there's no message, but this is specifically an imported
@@ -1365,7 +1368,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13651368 Printer.printAttrName (" @available" );
13661369 }
13671370 Printer << " (" ;
1368- printAvailableAttr (Attr, Printer, Options);
1371+ printAvailableAttr (D, Attr, Printer, Options);
13691372 Printer << " )" ;
13701373 break ;
13711374 }
@@ -1464,7 +1467,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
14641467 Printer << " availability: " ;
14651468 auto numAttrs = availAttrs.size ();
14661469 if (numAttrs == 1 ) {
1467- printAvailableAttr (availAttrs[0 ], Printer, Options);
1470+ printAvailableAttr (D, availAttrs[0 ], Printer, Options);
14681471 Printer << " ; " ;
14691472 } else {
14701473 SmallVector<const DeclAttribute *, 8 > tmp (availAttrs.begin (),
@@ -2223,19 +2226,21 @@ Type RawLayoutAttr::getResolvedCountType(StructDecl *sd) const {
22232226
22242227AvailableAttr::AvailableAttr (
22252228 SourceLoc AtLoc, SourceRange Range, PlatformKind Platform,
2226- StringRef Message, StringRef Rename, ValueDecl *RenameDecl,
2229+ StringRef Message, StringRef Rename,
22272230 const llvm::VersionTuple &Introduced, SourceRange IntroducedRange,
22282231 const llvm::VersionTuple &Deprecated, SourceRange DeprecatedRange,
22292232 const llvm::VersionTuple &Obsoleted, SourceRange ObsoletedRange,
22302233 PlatformAgnosticAvailabilityKind PlatformAgnostic, bool Implicit,
22312234 bool IsSPI, bool IsForEmbedded)
22322235 : DeclAttribute(DeclAttrKind::Available, AtLoc, Range, Implicit),
2233- Message(Message), Rename(Rename), RenameDecl(RenameDecl),
2236+ Message(Message), Rename(Rename),
22342237 INIT_VER_TUPLE(Introduced), IntroducedRange(IntroducedRange),
22352238 INIT_VER_TUPLE(Deprecated), DeprecatedRange(DeprecatedRange),
22362239 INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange) {
22372240 Bits.AvailableAttr .Platform = static_cast <uint8_t >(Platform);
22382241 Bits.AvailableAttr .PlatformAgnostic = static_cast <uint8_t >(PlatformAgnostic);
2242+ Bits.AvailableAttr .HasComputedRenamedDecl = false ;
2243+ Bits.AvailableAttr .HasRenamedDecl = false ;
22392244 Bits.AvailableAttr .IsSPI = IsSPI;
22402245
22412246 if (IsForEmbedded) {
@@ -2260,22 +2265,10 @@ AvailableAttr::createPlatformAgnostic(ASTContext &C,
22602265 assert (!Obsoleted.empty ());
22612266 }
22622267 return new (C) AvailableAttr (
2263- SourceLoc (), SourceRange (), PlatformKind::none, Message, Rename, nullptr ,
2264- NoVersion, SourceRange (),
2265- NoVersion, SourceRange (),
2266- Obsoleted, SourceRange (),
2267- Kind, /* isImplicit */ false , /* SPI*/ false );
2268- }
2269-
2270- AvailableAttr *AvailableAttr::createForAlternative (
2271- ASTContext &C, AbstractFunctionDecl *AsyncFunc) {
2272- llvm::VersionTuple NoVersion;
2273- return new (C) AvailableAttr (
2274- SourceLoc (), SourceRange (), PlatformKind::none, " " , " " , AsyncFunc,
2275- NoVersion, SourceRange (),
2276- NoVersion, SourceRange (),
2277- NoVersion, SourceRange (),
2278- PlatformAgnosticAvailabilityKind::None, /* Implicit=*/ true , /* SPI*/ false );
2268+ SourceLoc (), SourceRange (), PlatformKind::none, Message, Rename,
2269+ /* Introduced=*/ NoVersion, SourceRange (), /* Deprecated=*/ NoVersion,
2270+ SourceRange (), Obsoleted, SourceRange (), Kind, /* Implicit=*/ false ,
2271+ /* SPI=*/ false );
22792272}
22802273
22812274bool AvailableAttr::isActivePlatform (const ASTContext &ctx) const {
@@ -2288,19 +2281,16 @@ bool BackDeployedAttr::isActivePlatform(const ASTContext &ctx,
22882281}
22892282
22902283AvailableAttr *AvailableAttr::clone (ASTContext &C, bool implicit) const {
2291- return new (C) AvailableAttr (implicit ? SourceLoc () : AtLoc,
2292- implicit ? SourceRange () : getRange (),
2293- getPlatform (), Message, Rename, RenameDecl,
2294- Introduced ? *Introduced : llvm::VersionTuple (),
2295- implicit ? SourceRange () : IntroducedRange,
2296- Deprecated ? *Deprecated : llvm::VersionTuple (),
2297- implicit ? SourceRange () : DeprecatedRange,
2298- Obsoleted ? *Obsoleted : llvm::VersionTuple (),
2299- implicit ? SourceRange () : ObsoletedRange,
2300- getPlatformAgnosticAvailability (),
2301- implicit,
2302- isSPI (),
2303- isForEmbedded ());
2284+ return new (C) AvailableAttr (
2285+ implicit ? SourceLoc () : AtLoc, implicit ? SourceRange () : getRange (),
2286+ getPlatform (), Message, Rename,
2287+ Introduced ? *Introduced : llvm::VersionTuple (),
2288+ implicit ? SourceRange () : IntroducedRange,
2289+ Deprecated ? *Deprecated : llvm::VersionTuple (),
2290+ implicit ? SourceRange () : DeprecatedRange,
2291+ Obsoleted ? *Obsoleted : llvm::VersionTuple (),
2292+ implicit ? SourceRange () : ObsoletedRange,
2293+ getPlatformAgnosticAvailability (), implicit, isSPI (), isForEmbedded ());
23042294}
23052295
23062296std::optional<OriginallyDefinedInAttr::ActiveVersion>
0 commit comments