26enum class IsActive_t :
bool { Inactive, Active };
27enum class IsSubstitution_t :
bool { Original, Replacement };
29struct VersionedInfoMetadata {
32 unsigned IsActive : 1;
33 unsigned IsReplacement : 1;
35 VersionedInfoMetadata(VersionTuple Version, IsActive_t Active,
36 IsSubstitution_t Replacement)
37 : Version(Version), IsActive(Active == IsActive_t::Active),
38 IsReplacement(Replacement == IsSubstitution_t::Replacement) {}
54 VersionedInfoMetadata Metadata) {
55 if (!Metadata.IsActive)
65 return (QT.getTypePtr() != Original.getTypePtr()) ? std::optional(QT)
69 if (
auto Function = dyn_cast<FunctionDecl>(
D)) {
71 GetModified(
D,
Function->getReturnType(), Nullability)) {
75 *Modified, proto->getParamTypes(), proto->getExtProtoInfo()));
80 }
else if (
auto Method = dyn_cast<ObjCMethodDecl>(
D)) {
81 if (
auto Modified = GetModified(
D, Method->getReturnType(), Nullability)) {
82 Method->setReturnType(*Modified);
89 }
else if (
auto Value = dyn_cast<ValueDecl>(
D)) {
90 if (
auto Modified = GetModified(
D,
Value->
getType(), Nullability)) {
91 Value->setType(*Modified);
94 if (
auto Parm = dyn_cast<ParmVarDecl>(
D)) {
100 }
else if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
101 if (
auto Modified = GetModified(
D,
Property->getType(), Nullability)) {
114 void *mem = Ctx.
Allocate(String.size(),
alignof(
char *));
115 memcpy(mem, String.data(), String.size());
116 return StringRef(
static_cast<char *
>(mem), String.size());
128template <
typename A>
struct AttrKindFor {};
131 template <> struct AttrKindFor<X##Attr> { \
132 static const attr::Kind value = attr::X; \
134#include "clang/Basic/AttrList.inc"
142void handleAPINotedAttribute(
143 Sema &S,
Decl *
D,
bool IsAddition, VersionedInfoMetadata Metadata,
144 llvm::function_ref<A *()> CreateAttr,
146 if (Metadata.IsActive) {
147 auto Existing = GetExistingAttr(
D);
151 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
152 S.
Context, Metadata.Version, *Existing,
true);
160 if (
auto Attr = CreateAttr())
167 if (
auto Attr = CreateAttr()) {
168 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
170 Metadata.IsReplacement);
177 auto *Versioned = SwiftVersionedRemovalAttr::CreateImplicit(
178 S.
Context, Metadata.Version, AttrKindFor<A>::value,
179 Metadata.IsReplacement);
185void handleAPINotedAttribute(
Sema &S,
Decl *
D,
bool ShouldAddAttribute,
186 VersionedInfoMetadata Metadata,
187 llvm::function_ref<A *()> CreateAttr) {
188 handleAPINotedAttribute<A>(
189 S,
D, ShouldAddAttribute, Metadata, CreateAttr, [](
const Decl *
D) {
190 return llvm::find_if(
D->
attrs(),
191 [](
const Attr *Next) { return isa<A>(Next); });
198 bool ShouldAddAttribute,
199 VersionedInfoMetadata Metadata) {
202 handleAPINotedAttribute<A>(
203 S,
D, ShouldAddAttribute, Metadata,
206 return llvm::find_if(
D->
attrs(), [](
const Attr *Next) ->
bool {
207 return isa<CFReturnsRetainedAttr>(Next) ||
208 isa<CFReturnsNotRetainedAttr>(Next) ||
209 isa<NSReturnsRetainedAttr>(Next) ||
210 isa<NSReturnsNotRetainedAttr>(Next) ||
211 isa<CFAuditedTransferAttr>(Next);
217 Sema &S,
Decl *
D, VersionedInfoMetadata Metadata,
218 std::optional<api_notes::RetainCountConventionKind> Convention) {
221 switch (*Convention) {
222 case api_notes::RetainCountConventionKind::None:
223 if (isa<FunctionDecl>(
D)) {
224 handleAPINotedRetainCountAttribute<CFUnknownTransferAttr>(
225 S,
D,
true, Metadata);
227 handleAPINotedRetainCountAttribute<CFReturnsRetainedAttr>(
228 S,
D,
false, Metadata);
231 case api_notes::RetainCountConventionKind::CFReturnsRetained:
232 handleAPINotedRetainCountAttribute<CFReturnsRetainedAttr>(
233 S,
D,
true, Metadata);
235 case api_notes::RetainCountConventionKind::CFReturnsNotRetained:
236 handleAPINotedRetainCountAttribute<CFReturnsNotRetainedAttr>(
237 S,
D,
true, Metadata);
239 case api_notes::RetainCountConventionKind::NSReturnsRetained:
240 handleAPINotedRetainCountAttribute<NSReturnsRetainedAttr>(
241 S,
D,
true, Metadata);
243 case api_notes::RetainCountConventionKind::NSReturnsNotRetained:
244 handleAPINotedRetainCountAttribute<NSReturnsNotRetainedAttr>(
245 S,
D,
true, Metadata);
252 VersionedInfoMetadata Metadata) {
255 handleAPINotedAttribute<UnavailableAttr>(S,
D,
true, Metadata, [&] {
263 handleAPINotedAttribute<AvailabilityAttr>(
264 S,
D,
true, Metadata,
266 return new (S.
Context) AvailabilityAttr(
278 return llvm::find_if(
D->
attrs(), [](
const Attr *next) ->
bool {
279 if (const auto *AA = dyn_cast<AvailabilityAttr>(next))
280 if (const auto *II = AA->getPlatform())
281 return II->isStr(
"swift");
289 handleAPINotedAttribute<SwiftPrivateAttr>(
290 S,
D, *SwiftPrivate, Metadata, [&] {
298 handleAPINotedAttribute<SwiftNameAttr>(
299 S,
D,
true, Metadata, [&]() -> SwiftNameAttr * {
304 AP.create(&
C.Idents.get(
"swift_name"),
SourceRange(),
nullptr,
306 ParsedAttr::Form::GNU());
321 VersionedInfoMetadata Metadata) {
324 handleAPINotedAttribute<SwiftBridgeAttr>(
325 S,
D, !SwiftBridge->empty(), Metadata, [&] {
326 return new (S.Context)
327 SwiftBridgeAttr(S.Context, getPlaceholderAttrInfo(),
328 ASTAllocateString(S.Context, *SwiftBridge));
334 handleAPINotedAttribute<NSErrorDomainAttr>(
335 S,
D, !NSErrorDomain->empty(), Metadata, [&] {
336 return new (S.Context)
337 NSErrorDomainAttr(S.Context, getPlaceholderAttrInfo(),
338 &S.Context.Idents.get(*NSErrorDomain));
354 S.
Diag(
Loc, diag::err_incompatible_replacement_type)
355 << ReplacementType << OrigType;
365 VersionedInfoMetadata Metadata) {
367 if (Metadata.IsActive && !Info.
getType().empty() &&
376 if (
auto Var = dyn_cast<VarDecl>(
D)) {
378 if (isa<ParmVarDecl>(Var)) {
389 }
else if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
395 llvm_unreachable(
"API notes allowed a type on an unknown declaration");
411 VersionedInfoMetadata Metadata) {
414 handleAPINotedAttribute<NoEscapeAttr>(S,
D, *NoEscape, Metadata, [&] {
430 VersionedInfoMetadata metadata) {
439 VersionedInfoMetadata Metadata) {
445 handleAPINotedAttribute<SwiftImportPropertyAsAccessorsAttr>(
446 S,
D, *AsAccessors, Metadata, [&] {
447 return new (S.
Context) SwiftImportPropertyAsAccessorsAttr(
454typedef llvm::PointerUnion<FunctionDecl *, ObjCMethodDecl *> FunctionOrMethod;
460 VersionedInfoMetadata Metadata) {
470 assert((FD || MD) &&
"Expecting Function or ObjCMethod");
479 bool AnyTypeChanged =
false;
480 for (
unsigned I = 0; I != NumParams; ++I) {
484 if (I < Info.
Params.size())
492 AnyTypeChanged =
true;
497 if (Metadata.IsActive && !Info.
ResultType.empty() &&
507 auto ResultTypeInfo =
514 OverriddenResultType = ResultType;
515 AnyTypeChanged =
true;
522 if (FD && AnyTypeChanged) {
524 if (OverriddenResultType.
isNull())
525 OverriddenResultType = fnProtoType->getReturnType();
529 ParamTypes.push_back(Param->getType());
532 fnProtoType->getExtProtoInfo()));
533 }
else if (!OverriddenResultType.
isNull()) {
536 OverriddenResultType, FnNoProtoType->getExtInfo()));
552 VersionedInfoMetadata Metadata) {
559 VersionedInfoMetadata Metadata) {
568 VersionedInfoMetadata Metadata) {
577 VersionedInfoMetadata Metadata) {
580 handleAPINotedAttribute<ObjCDesignatedInitializerAttr>(
581 S,
D,
true, Metadata, [&] {
583 IFace->setHasDesignatedInitializers();
585 return new (S.
Context) ObjCDesignatedInitializerAttr(
597 VersionedInfoMetadata Metadata) {
599 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"import_" + ImportAs.value()));
602 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"retain:" + RetainOp.value()));
606 SwiftAttrAttr::Create(S.
Context,
"release:" + ReleaseOp.value()));
615 bool ShouldAddAttribute = (*Extensibility != EnumExtensibilityKind::None);
616 handleAPINotedAttribute<EnumExtensibilityAttr>(
617 S,
D, ShouldAddAttribute, Metadata, [&] {
618 EnumExtensibilityAttr::Kind kind;
619 switch (*Extensibility) {
620 case EnumExtensibilityKind::None:
621 llvm_unreachable(
"remove only");
622 case EnumExtensibilityKind::Open:
623 kind = EnumExtensibilityAttr::Open;
625 case EnumExtensibilityKind::Closed:
626 kind = EnumExtensibilityAttr::Closed;
635 handleAPINotedAttribute<FlagEnumAttr>(S,
D, *FlagEnum, Metadata, [&] {
648 VersionedInfoMetadata Metadata) {
653 handleAPINotedAttribute<SwiftNewTypeAttr>(
654 S,
D, *SwiftWrapper != SwiftWrapperKind::None, Metadata, [&] {
655 SwiftNewTypeAttr::NewtypeKind Kind;
656 switch (*SwiftWrapper) {
657 case SwiftWrapperKind::None:
658 llvm_unreachable(
"Shouldn't build an attribute");
660 case SwiftWrapperKind::Struct:
661 Kind = SwiftNewTypeAttr::NK_Struct;
664 case SwiftWrapperKind::Enum:
665 Kind = SwiftNewTypeAttr::NK_Enum;
670 AttributeCommonInfo::AT_SwiftNewType,
673 return new (S.
Context) SwiftNewTypeAttr(S.
Context, SyntaxInfo, Kind);
685 VersionedInfoMetadata Metadata) {
694 VersionedInfoMetadata Metadata) {
696 handleAPINotedAttribute<SwiftImportAsNonGenericAttr>(
697 S,
D, *AsNonGeneric, Metadata, [&] {
704 handleAPINotedAttribute<SwiftObjCMembersAttr>(
705 S,
D, *ObjcMembers, Metadata, [&] {
724template <
typename SpecificInfo>
734 VersionTuple SelectedVersion;
735 SpecificInfo SelectedInfoSlice;
736 std::tie(SelectedVersion, SelectedInfoSlice) = Info[*Info.
getSelected()];
737 if (SelectedVersion.empty())
739 if (SelectedInfoSlice.SwiftName.empty())
743 for (
const auto &VersionAndInfoSlice : Info) {
744 if (!VersionAndInfoSlice.first.empty())
746 if (!VersionAndInfoSlice.second.SwiftName.empty())
751 VersionedInfoMetadata DummyFutureMetadata(
752 SelectedVersion, IsActive_t::Inactive, IsSubstitution_t::Replacement);
753 handleAPINotedAttribute<SwiftNameAttr>(
754 S,
D,
false, DummyFutureMetadata, []() -> SwiftNameAttr * {
755 llvm_unreachable(
"should not try to add an attribute here");
762template <
typename SpecificDecl,
typename SpecificInfo>
764 Sema &S, SpecificDecl *
D,
771 VersionTuple Version;
772 SpecificInfo InfoSlice;
773 for (
unsigned i = 0, e = Info.
size(); i != e; ++i) {
774 std::tie(Version, InfoSlice) = Info[i];
775 auto Active = (i == Selected) ? IsActive_t::Active : IsActive_t::Inactive;
776 auto Replacement = IsSubstitution_t::Original;
777 if (Active == IsActive_t::Inactive && Version.empty()) {
778 Replacement = IsSubstitution_t::Replacement;
779 Version = Info[Selected].first;
782 VersionedInfoMetadata(Version, Active, Replacement));
786static std::optional<api_notes::Context>
788 if (
auto NamespaceContext = dyn_cast<NamespaceDecl>(DC)) {
789 for (
auto Reader : APINotes.
findAPINotes(NamespaceContext->getLocation())) {
791 std::stack<NamespaceDecl *> NamespaceStack;
793 for (
auto CurrentNamespace = NamespaceContext; CurrentNamespace;
795 dyn_cast<NamespaceDecl>(CurrentNamespace->getParent())) {
796 if (!CurrentNamespace->isInlineNamespace())
797 NamespaceStack.push(CurrentNamespace);
800 std::optional<api_notes::ContextID> NamespaceID;
801 while (!NamespaceStack.empty()) {
802 auto CurrentNamespace = NamespaceStack.top();
803 NamespaceStack.pop();
805 Reader->lookupNamespaceID(CurrentNamespace->getName(), NamespaceID);
811 api_notes::ContextKind::Namespace);
817static std::optional<api_notes::Context>
819 assert(DC &&
"tag context must not be null");
822 std::stack<TagDecl *> TagStack;
824 for (
auto CurrentTag = DC; CurrentTag;
825 CurrentTag = dyn_cast<TagDecl>(CurrentTag->getParent()))
826 TagStack.push(CurrentTag);
828 assert(!TagStack.empty());
829 std::optional<api_notes::Context> Ctx =
831 while (!TagStack.empty()) {
832 auto CurrentTag = TagStack.top();
834 auto CtxID = Reader->lookupTagID(CurrentTag->getName(), Ctx);
855 std::optional<api_notes::Context> APINotesContext =
858 if (
auto VD = dyn_cast<VarDecl>(
D)) {
861 Reader->lookupGlobalVariable(VD->getName(), APINotesContext);
869 if (
auto FD = dyn_cast<FunctionDecl>(
D)) {
870 if (FD->getDeclName().isIdentifier()) {
873 Reader->lookupGlobalFunction(FD->getName(), APINotesContext);
882 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(
D)) {
884 auto Info = Reader->lookupObjCClassInfo(
Class->getName());
892 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(
D)) {
894 auto Info = Reader->lookupObjCProtocolInfo(Protocol->getName());
902 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
903 std::string
LookupName = Tag->getName().str();
910 std::string MacroName =
911 LookupName.empty() && Tag->getOuterLocStart().isMacroID()
913 Tag->getOuterLocStart(),
914 Tag->getASTContext().getSourceManager(),
LangOpts)
918 if (
LookupName.empty() && isa<clang::EnumDecl>(Tag) &&
919 (MacroName ==
"CF_OPTIONS" || MacroName ==
"NS_OPTIONS" ||
920 MacroName ==
"OBJC_OPTIONS" || MacroName ==
"SWIFT_OPTIONS")) {
928 if (
auto ParentTag = dyn_cast<TagDecl>(Tag->getDeclContext()))
930 auto Info = Reader->lookupTag(
LookupName, APINotesContext);
938 if (
auto Typedef = dyn_cast<TypedefNameDecl>(
D)) {
940 auto Info = Reader->lookupTypedef(Typedef->getName(), APINotesContext);
951 if (
auto EnumConstant = dyn_cast<EnumConstantDecl>(
D)) {
953 auto Info = Reader->lookupEnumConstant(EnumConstant->getName());
961 if (
auto ObjCContainer = dyn_cast<ObjCContainerDecl>(
D->
getDeclContext())) {
964 -> std::optional<api_notes::ContextID> {
965 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(ObjCContainer)) {
966 if (
auto Found = Reader->lookupObjCProtocolID(Protocol->getName()))
972 if (
auto Impl = dyn_cast<ObjCCategoryImplDecl>(ObjCContainer)) {
973 if (
auto Cat = Impl->getCategoryDecl())
974 ObjCContainer = Cat->getClassInterface();
979 if (
auto Category = dyn_cast<ObjCCategoryDecl>(ObjCContainer)) {
981 ObjCContainer =
Category->getClassInterface();
986 if (
auto Impl = dyn_cast<ObjCImplDecl>(ObjCContainer)) {
987 if (Impl->getClassInterface())
988 ObjCContainer = Impl->getClassInterface();
993 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(ObjCContainer)) {
994 if (
auto Found = Reader->lookupObjCClassID(
Class->getName()))
1000 return std::nullopt;
1004 if (
auto Method = dyn_cast<ObjCMethodDecl>(
D)) {
1006 if (
auto Context = GetContext(Reader)) {
1008 Selector Sel = Method->getSelector();
1013 for (
unsigned i = 0, n = Sel.
getNumArgs(); i != n; ++i)
1021 auto Info = Reader->lookupObjCMethod(*
Context, SelectorRef,
1022 Method->isInstanceMethod());
1029 if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
1031 if (
auto Context = GetContext(Reader)) {
1032 bool isInstanceProperty =
1033 (
Property->getPropertyAttributesAsWritten() &
1036 isInstanceProperty);
1046 if (
auto CXXMethod = dyn_cast<CXXMethodDecl>(
D)) {
1047 if (!isa<CXXConstructorDecl>(CXXMethod) &&
1048 !isa<CXXDestructorDecl>(CXXMethod) &&
1049 !isa<CXXConversionDecl>(CXXMethod) &&
1050 !CXXMethod->isOverloadedOperator()) {
1054 Reader->lookupCXXMethod(
Context->id, CXXMethod->getName());
1061 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
1064 auto Info = Reader->lookupTag(Tag->getName(),
Context);
static std::optional< api_notes::Context > UnwindNamespaceContext(DeclContext *DC, api_notes::APINotesManager &APINotes)
static void ProcessVersionedAPINotes(Sema &S, SpecificDecl *D, const api_notes::APINotesReader::VersionedInfo< SpecificInfo > Info)
Processes all versions of versioned API notes.
static bool checkAPINotesReplacementType(Sema &S, SourceLocation Loc, QualType OrigType, QualType ReplacementType)
Check that the replacement type provided by API notes is reasonable.
static void applyNullability(Sema &S, Decl *D, NullabilityKind Nullability, VersionedInfoMetadata Metadata)
Apply nullability to the given declaration.
static std::optional< api_notes::Context > UnwindTagContext(TagDecl *DC, api_notes::APINotesManager &APINotes)
static StringRef ASTAllocateString(ASTContext &Ctx, StringRef String)
Copy a string into ASTContext-allocated memory.
static void handleAPINotedRetainCountConvention(Sema &S, Decl *D, VersionedInfoMetadata Metadata, std::optional< api_notes::RetainCountConventionKind > Convention)
static void handleAPINotedRetainCountAttribute(Sema &S, Decl *D, bool ShouldAddAttribute, VersionedInfoMetadata Metadata)
static AttributeCommonInfo getPlaceholderAttrInfo()
static void ProcessAPINotes(Sema &S, Decl *D, const api_notes::CommonEntityInfo &Info, VersionedInfoMetadata Metadata)
static void maybeAttachUnversionedSwiftName(Sema &S, Decl *D, const api_notes::APINotesReader::VersionedInfo< SpecificInfo > Info)
If we're applying API notes with an active, non-default version, and the versioned API notes have a S...
static bool isIndirectPointerType(QualType Type)
Determine whether this is a multi-level pointer type.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis functions specific to Swift.
Defines the clang::SourceLocation class and associated facilities.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void * Allocate(size_t Size, unsigned Align=8) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
Attr - This represents one attribute.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
Represents a static or instance method of a struct/union/class.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Decl - This represents one declaration (or definition), e.g.
attr_iterator attr_end() const
AttrVec::const_iterator attr_iterator
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
SourceLocation getLocation() const
DeclContext * getDeclContext()
An instance of this object exists for each enum constant that is defined.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static StringRef getImmediateMacroName(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
ObjCContainerDecl - Represents a container for method declarations.
Represents an ObjC class declaration.
ObjCMethodDecl - Represents an instance or class method declaration.
unsigned param_size() const
void setReturnTypeSourceInfo(TypeSourceInfo *TInfo)
param_const_iterator param_begin() const
void setReturnType(QualType T)
QualType getReturnType() const
Represents one property declaration in an Objective-C interface.
Represents a parameter to a function.
ParsedAttr - Represents a syntactic attribute.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
std::string getAsString() const
void * getAsOpaquePtr() const
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isUnarySelector() const
unsigned getNumArgs() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
QualType AdjustParameterTypeForObjCAutoRefCount(QualType T, SourceLocation NameLoc, TypeSourceInfo *TSInfo)
bool DiagnoseName(Decl *D, StringRef Name, SourceLocation Loc, const ParsedAttr &AL, bool IsAsync)
Do a check to make sure Name looks like a legal argument for the swift_name attribute applied to decl...
Sema - This implements semantic analysis and AST building for C.
ASTContext & getASTContext() const
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
api_notes::APINotesManager APINotes
const LangOptions & LangOpts
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
bool CheckImplicitNullabilityTypeSpecifier(QualType &Type, NullabilityKind Nullability, SourceLocation DiagLoc, bool AllowArrayTypes, bool OverrideExisting)
Check whether a nullability type specifier can be added to the given type through some means not writ...
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Encodes a location in the source.
A trivial tuple used to represent a source range.
Represents the declaration of a struct/union/class/enum.
The base class of the type hierarchy.
const T * castAs() const
Member-template castAs<specific type>.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isMemberPointerType() const
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
void setType(QualType newType)
Represents a variable declaration or definition.
The API notes manager helps find API notes associated with declarations.
llvm::SmallVector< APINotesReader *, 2 > findAPINotes(SourceLocation Loc)
Find the API notes readers that correspond to the given source location.
Captures the completed versioned information for a particular part of API notes, including both unver...
unsigned size() const
Return the number of versioned results we know about.
std::optional< unsigned > getSelected() const
Retrieve the selected index in the result set.
A class that reads API notes data from a binary file that was written by the APINotesWriter.
Describes API notes data for a C++ method.
Describes API notes data for any entity.
unsigned UnavailableInSwift
Whether this entity is marked unavailable in Swift.
unsigned Unavailable
Whether this entity is marked unavailable.
std::string SwiftName
Swift name of this entity.
std::string UnavailableMsg
Message to use when this entity is unavailable.
std::optional< bool > isSwiftPrivate() const
Describes API notes for types.
const std::optional< std::string > & getSwiftBridge() const
const std::optional< std::string > & getNSErrorDomain() const
Describes API notes data for an Objective-C class or protocol or a C++ namespace.
std::optional< bool > getSwiftImportAsNonGeneric() const
std::optional< bool > getSwiftObjCMembers() const
Describes API notes data for an enumerator.
API notes for a function or method.
std::optional< RetainCountConventionKind > getRetainCountConvention() const
std::vector< ParamInfo > Params
The function parameters.
NullabilityKind getReturnTypeInfo() const
NullabilityKind getParamTypeInfo(unsigned index) const
std::string ResultType
The result type of this function, as a C type.
unsigned NullabilityAudited
Whether the signature has been audited with respect to nullability.
Describes API notes data for a global function.
Describes API notes data for a global variable.
Describes API notes data for an Objective-C method.
unsigned DesignatedInit
Whether this is a designated initializer of its class.
Describes API notes data for an Objective-C property.
std::optional< bool > getSwiftImportAsAccessors() const
Describes a function or method parameter.
std::optional< bool > isNoEscape() const
std::optional< RetainCountConventionKind > getRetainCountConvention() const
Describes API notes data for a tag.
std::optional< std::string > SwiftReleaseOp
std::optional< std::string > SwiftRetainOp
std::optional< std::string > SwiftImportAs
std::optional< EnumExtensibilityKind > EnumExtensibility
std::optional< bool > isFlagEnum() const
std::optional< bool > isSwiftCopyable() const
Describes API notes data for a typedef.
std::optional< SwiftNewTypeKind > SwiftWrapper
API notes for a variable/property.
std::optional< NullabilityKind > getNullability() const
const std::string & getType() const
SwiftNewTypeKind
The kind of a swift_wrapper/swift_newtype.
EnumExtensibilityKind
The payload for an enum_extensibility attribute.
The JSON file list parser is used to communicate input to InstallAPI.
NullabilityKind
Describes the nullability of a particular type.
@ Property
The type of a property.
const FunctionProtoType * T
@ Class
The "class" keyword introduces the elaborated-type-specifier.
A temporary reference to an Objective-C selector, suitable for referencing selector data on the stack...
llvm::ArrayRef< llvm::StringRef > Identifiers