@@ -629,7 +629,7 @@ class AvailableAttr : public DeclAttribute {
629629
630630 AvailableAttr (SourceLoc AtLoc, SourceRange Range,
631631 PlatformKind Platform,
632- StringRef Message, StringRef Rename,
632+ StringRef Message, StringRef Rename, ValueDecl *RenameDecl,
633633 const llvm::VersionTuple &Introduced,
634634 SourceRange IntroducedRange,
635635 const llvm::VersionTuple &Deprecated,
@@ -639,7 +639,7 @@ class AvailableAttr : public DeclAttribute {
639639 PlatformAgnosticAvailabilityKind PlatformAgnostic,
640640 bool Implicit)
641641 : DeclAttribute(DAK_Available, AtLoc, Range, Implicit),
642- Message (Message), Rename(Rename),
642+ Message (Message), Rename(Rename), RenameDecl(RenameDecl),
643643 INIT_VER_TUPLE(Introduced), IntroducedRange(IntroducedRange),
644644 INIT_VER_TUPLE(Deprecated), DeprecatedRange(DeprecatedRange),
645645 INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange),
@@ -660,6 +660,12 @@ class AvailableAttr : public DeclAttribute {
660660 // / the `NS_SWIFT_NAME` annotation in Objective-C.
661661 const StringRef Rename;
662662
663+ // / The declaration referred to by \c Rename. Note that this is only set for
664+ // / deserialized attributes or inferred attributes from ObjectiveC code.
665+ // / \c ValueDecl::getRenamedDecl should be used to find the declaration
666+ // / corresponding to \c Rename.
667+ ValueDecl *RenameDecl;
668+
663669 // / Indicates when the symbol was introduced.
664670 const Optional<llvm::VersionTuple> Introduced;
665671
@@ -746,6 +752,11 @@ class AvailableAttr : public DeclAttribute {
746752 llvm::VersionTuple Obsoleted
747753 = llvm::VersionTuple());
748754
755+ // / Create an AvailableAttr that indicates the given \p AsyncFunc should be
756+ // / preferentially used in async contexts
757+ static AvailableAttr *createForAlternative (ASTContext &C,
758+ AbstractFunctionDecl *AsyncFunc);
759+
749760 AvailableAttr *clone (ASTContext &C, bool implicit) const ;
750761
751762 static bool classof (const DeclAttribute *DA) {
@@ -2021,57 +2032,6 @@ class TransposeAttr final
20212032 }
20222033};
20232034
2024- // / The `@completionHandlerAsync` attribute marks a function as having an async
2025- // / alternative, optionally providing a name (for cases when the alternative
2026- // / has a different name).
2027- class CompletionHandlerAsyncAttr final : public DeclAttribute {
2028- public:
2029- // / Reference to the async alternative function. Only set for deserialized
2030- // / attributes or inferred attributes from ObjectiveC code.
2031- AbstractFunctionDecl *AsyncFunctionDecl;
2032-
2033- // / DeclName of the async function in the attribute. Only set from actual
2034- // / Swift code, deserialization/ObjectiveC imports will set the decl instead.
2035- const DeclNameRef AsyncFunctionName;
2036-
2037- // / Source location of the async function name in the attribute
2038- const SourceLoc AsyncFunctionNameLoc;
2039-
2040- // / The index of the completion handler
2041- const size_t CompletionHandlerIndex;
2042-
2043- // / Source location of the completion handler index passed to the index
2044- const SourceLoc CompletionHandlerIndexLoc;
2045-
2046- CompletionHandlerAsyncAttr (DeclNameRef asyncFunctionName,
2047- SourceLoc asyncFunctionNameLoc,
2048- size_t completionHandlerIndex,
2049- SourceLoc completionHandlerIndexLoc,
2050- SourceLoc atLoc, SourceRange range)
2051- : DeclAttribute(DAK_CompletionHandlerAsync, atLoc, range,
2052- /* implicit*/ false ),
2053- AsyncFunctionDecl (nullptr ),
2054- AsyncFunctionName(asyncFunctionName),
2055- AsyncFunctionNameLoc(asyncFunctionNameLoc),
2056- CompletionHandlerIndex(completionHandlerIndex),
2057- CompletionHandlerIndexLoc(completionHandlerIndexLoc) {}
2058-
2059- CompletionHandlerAsyncAttr (AbstractFunctionDecl &asyncFunctionDecl,
2060- size_t completionHandlerIndex,
2061- SourceLoc completionHandlerIndexLoc,
2062- SourceLoc atLoc, SourceRange range,
2063- bool implicit)
2064- : DeclAttribute(DAK_CompletionHandlerAsync, atLoc, range,
2065- implicit),
2066- AsyncFunctionDecl(&asyncFunctionDecl) ,
2067- CompletionHandlerIndex(completionHandlerIndex),
2068- CompletionHandlerIndexLoc(completionHandlerIndexLoc) {}
2069-
2070- static bool classof (const DeclAttribute *DA) {
2071- return DA->getKind () == DAK_CompletionHandlerAsync;
2072- }
2073- };
2074-
20752035// / Attributes that may be applied to declarations.
20762036class DeclAttributes {
20772037 // / Linked list of declaration attributes.
0 commit comments