@@ -1113,7 +1113,8 @@ ParsedDeclAttrFilter::operator()(const DeclAttribute *Attr) const {
1113
1113
return Attr;
1114
1114
}
1115
1115
1116
- static void printAvailableAttr (const AvailableAttr *Attr, ASTPrinter &Printer,
1116
+ static void printAvailableAttr (const Decl *D, const AvailableAttr *Attr,
1117
+ ASTPrinter &Printer,
1117
1118
const PrintOptions &Options) {
1118
1119
if (Attr->isLanguageVersionSpecific ())
1119
1120
Printer << " swift" ;
@@ -1138,17 +1139,19 @@ static void printAvailableAttr(const AvailableAttr *Attr, ASTPrinter &Printer,
1138
1139
1139
1140
if (!Attr->Rename .empty ()) {
1140
1141
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 << " \" " ;
1150
1154
}
1151
- Printer << " \" " ;
1152
1155
}
1153
1156
1154
1157
// If there's no message, but this is specifically an imported
@@ -1365,7 +1368,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
1365
1368
Printer.printAttrName (" @available" );
1366
1369
}
1367
1370
Printer << " (" ;
1368
- printAvailableAttr (Attr, Printer, Options);
1371
+ printAvailableAttr (D, Attr, Printer, Options);
1369
1372
Printer << " )" ;
1370
1373
break ;
1371
1374
}
@@ -1464,7 +1467,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
1464
1467
Printer << " availability: " ;
1465
1468
auto numAttrs = availAttrs.size ();
1466
1469
if (numAttrs == 1 ) {
1467
- printAvailableAttr (availAttrs[0 ], Printer, Options);
1470
+ printAvailableAttr (D, availAttrs[0 ], Printer, Options);
1468
1471
Printer << " ; " ;
1469
1472
} else {
1470
1473
SmallVector<const DeclAttribute *, 8 > tmp (availAttrs.begin (),
@@ -2223,19 +2226,21 @@ Type RawLayoutAttr::getResolvedCountType(StructDecl *sd) const {
2223
2226
2224
2227
AvailableAttr::AvailableAttr (
2225
2228
SourceLoc AtLoc, SourceRange Range, PlatformKind Platform,
2226
- StringRef Message, StringRef Rename, ValueDecl *RenameDecl,
2229
+ StringRef Message, StringRef Rename,
2227
2230
const llvm::VersionTuple &Introduced, SourceRange IntroducedRange,
2228
2231
const llvm::VersionTuple &Deprecated, SourceRange DeprecatedRange,
2229
2232
const llvm::VersionTuple &Obsoleted, SourceRange ObsoletedRange,
2230
2233
PlatformAgnosticAvailabilityKind PlatformAgnostic, bool Implicit,
2231
2234
bool IsSPI, bool IsForEmbedded)
2232
2235
: DeclAttribute(DeclAttrKind::Available, AtLoc, Range, Implicit),
2233
- Message(Message), Rename(Rename), RenameDecl(RenameDecl),
2236
+ Message(Message), Rename(Rename),
2234
2237
INIT_VER_TUPLE(Introduced), IntroducedRange(IntroducedRange),
2235
2238
INIT_VER_TUPLE(Deprecated), DeprecatedRange(DeprecatedRange),
2236
2239
INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange) {
2237
2240
Bits.AvailableAttr .Platform = static_cast <uint8_t >(Platform);
2238
2241
Bits.AvailableAttr .PlatformAgnostic = static_cast <uint8_t >(PlatformAgnostic);
2242
+ Bits.AvailableAttr .HasComputedRenamedDecl = false ;
2243
+ Bits.AvailableAttr .HasRenamedDecl = false ;
2239
2244
Bits.AvailableAttr .IsSPI = IsSPI;
2240
2245
2241
2246
if (IsForEmbedded) {
@@ -2260,22 +2265,10 @@ AvailableAttr::createPlatformAgnostic(ASTContext &C,
2260
2265
assert (!Obsoleted.empty ());
2261
2266
}
2262
2267
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 );
2279
2272
}
2280
2273
2281
2274
bool AvailableAttr::isActivePlatform (const ASTContext &ctx) const {
@@ -2288,19 +2281,16 @@ bool BackDeployedAttr::isActivePlatform(const ASTContext &ctx,
2288
2281
}
2289
2282
2290
2283
AvailableAttr *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 ());
2304
2294
}
2305
2295
2306
2296
std::optional<OriginallyDefinedInAttr::ActiveVersion>
0 commit comments