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) {
448 VersionedInfoMetadata Metadata) {
454 handleAPINotedAttribute<SwiftImportPropertyAsAccessorsAttr>(
455 S,
D, *AsAccessors, Metadata, [&] {
456 return new (S.
Context) SwiftImportPropertyAsAccessorsAttr(
463typedef llvm::PointerUnion<FunctionDecl *, ObjCMethodDecl *> FunctionOrMethod;
469 VersionedInfoMetadata Metadata) {
479 assert((FD || MD) &&
"Expecting Function or ObjCMethod");
488 bool AnyTypeChanged =
false;
489 for (
unsigned I = 0; I != NumParams; ++I) {
493 if (I < Info.
Params.size())
501 AnyTypeChanged =
true;
506 if (Metadata.IsActive && !Info.
ResultType.empty() &&
516 auto ResultTypeInfo =
523 OverriddenResultType = ResultType;
524 AnyTypeChanged =
true;
531 if (FD && AnyTypeChanged) {
533 if (OverriddenResultType.
isNull())
534 OverriddenResultType = fnProtoType->getReturnType();
538 ParamTypes.push_back(Param->getType());
541 fnProtoType->getExtProtoInfo()));
542 }
else if (!OverriddenResultType.
isNull()) {
545 OverriddenResultType, FnNoProtoType->getExtInfo()));
561 VersionedInfoMetadata Metadata) {
568 VersionedInfoMetadata Metadata) {
577 VersionedInfoMetadata Metadata) {
586 VersionedInfoMetadata Metadata) {
589 handleAPINotedAttribute<ObjCDesignatedInitializerAttr>(
590 S,
D,
true, Metadata, [&] {
592 IFace->setHasDesignatedInitializers();
594 return new (S.
Context) ObjCDesignatedInitializerAttr(
606 VersionedInfoMetadata Metadata) {
608 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"import_" + ImportAs.value()));
611 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"retain:" + RetainOp.value()));
615 SwiftAttrAttr::Create(S.
Context,
"release:" + ReleaseOp.value()));
619 SwiftAttrAttr::Create(S.
Context,
"conforms_to:" + ConformsTo.value()));
628 bool ShouldAddAttribute = (*Extensibility != EnumExtensibilityKind::None);
629 handleAPINotedAttribute<EnumExtensibilityAttr>(
630 S,
D, ShouldAddAttribute, Metadata, [&] {
631 EnumExtensibilityAttr::Kind kind;
632 switch (*Extensibility) {
633 case EnumExtensibilityKind::None:
634 llvm_unreachable(
"remove only");
635 case EnumExtensibilityKind::Open:
636 kind = EnumExtensibilityAttr::Open;
638 case EnumExtensibilityKind::Closed:
639 kind = EnumExtensibilityAttr::Closed;
648 handleAPINotedAttribute<FlagEnumAttr>(S,
D, *FlagEnum, Metadata, [&] {
661 VersionedInfoMetadata Metadata) {
666 handleAPINotedAttribute<SwiftNewTypeAttr>(
667 S,
D, *SwiftWrapper != SwiftWrapperKind::None, Metadata, [&] {
668 SwiftNewTypeAttr::NewtypeKind Kind;
669 switch (*SwiftWrapper) {
670 case SwiftWrapperKind::None:
671 llvm_unreachable(
"Shouldn't build an attribute");
673 case SwiftWrapperKind::Struct:
674 Kind = SwiftNewTypeAttr::NK_Struct;
677 case SwiftWrapperKind::Enum:
678 Kind = SwiftNewTypeAttr::NK_Enum;
683 AttributeCommonInfo::AT_SwiftNewType,
686 return new (S.
Context) SwiftNewTypeAttr(S.
Context, SyntaxInfo, Kind);
698 VersionedInfoMetadata Metadata) {
707 VersionedInfoMetadata Metadata) {
709 handleAPINotedAttribute<SwiftImportAsNonGenericAttr>(
710 S,
D, *AsNonGeneric, Metadata, [&] {
717 handleAPINotedAttribute<SwiftObjCMembersAttr>(
718 S,
D, *ObjcMembers, Metadata, [&] {
737template <
typename SpecificInfo>
747 VersionTuple SelectedVersion;
748 SpecificInfo SelectedInfoSlice;
749 std::tie(SelectedVersion, SelectedInfoSlice) = Info[*Info.
getSelected()];
750 if (SelectedVersion.empty())
752 if (SelectedInfoSlice.SwiftName.empty())
756 for (
const auto &VersionAndInfoSlice : Info) {
757 if (!VersionAndInfoSlice.first.empty())
759 if (!VersionAndInfoSlice.second.SwiftName.empty())
764 VersionedInfoMetadata DummyFutureMetadata(
765 SelectedVersion, IsActive_t::Inactive, IsSubstitution_t::Replacement);
766 handleAPINotedAttribute<SwiftNameAttr>(
767 S,
D,
false, DummyFutureMetadata, []() -> SwiftNameAttr * {
768 llvm_unreachable(
"should not try to add an attribute here");
775template <
typename SpecificDecl,
typename SpecificInfo>
777 Sema &S, SpecificDecl *
D,
784 VersionTuple Version;
785 SpecificInfo InfoSlice;
786 for (
unsigned i = 0, e = Info.
size(); i != e; ++i) {
787 std::tie(Version, InfoSlice) = Info[i];
788 auto Active = (i == Selected) ? IsActive_t::Active : IsActive_t::Inactive;
789 auto Replacement = IsSubstitution_t::Original;
790 if (Active == IsActive_t::Inactive && Version.empty()) {
791 Replacement = IsSubstitution_t::Replacement;
792 Version = Info[Selected].first;
795 VersionedInfoMetadata(Version, Active, Replacement));
799static std::optional<api_notes::Context>
801 if (
auto NamespaceContext = dyn_cast<NamespaceDecl>(DC)) {
802 for (
auto Reader : APINotes.
findAPINotes(NamespaceContext->getLocation())) {
804 std::stack<NamespaceDecl *> NamespaceStack;
806 for (
auto CurrentNamespace = NamespaceContext; CurrentNamespace;
808 dyn_cast<NamespaceDecl>(CurrentNamespace->getParent())) {
809 if (!CurrentNamespace->isInlineNamespace())
810 NamespaceStack.push(CurrentNamespace);
813 std::optional<api_notes::ContextID> NamespaceID;
814 while (!NamespaceStack.empty()) {
815 auto CurrentNamespace = NamespaceStack.top();
816 NamespaceStack.pop();
818 Reader->lookupNamespaceID(CurrentNamespace->getName(), NamespaceID);
824 api_notes::ContextKind::Namespace);
830static std::optional<api_notes::Context>
832 assert(DC &&
"tag context must not be null");
835 std::stack<TagDecl *> TagStack;
837 for (
auto CurrentTag = DC; CurrentTag;
838 CurrentTag = dyn_cast<TagDecl>(CurrentTag->getParent()))
839 TagStack.push(CurrentTag);
841 assert(!TagStack.empty());
842 std::optional<api_notes::Context> Ctx =
844 while (!TagStack.empty()) {
845 auto CurrentTag = TagStack.top();
847 auto CtxID = Reader->lookupTagID(CurrentTag->getName(), Ctx);
868 std::optional<api_notes::Context> APINotesContext =
871 if (
auto VD = dyn_cast<VarDecl>(
D)) {
874 Reader->lookupGlobalVariable(VD->getName(), APINotesContext);
882 if (
auto FD = dyn_cast<FunctionDecl>(
D)) {
883 if (FD->getDeclName().isIdentifier()) {
886 Reader->lookupGlobalFunction(FD->getName(), APINotesContext);
895 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(
D)) {
897 auto Info = Reader->lookupObjCClassInfo(
Class->getName());
905 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(
D)) {
907 auto Info = Reader->lookupObjCProtocolInfo(Protocol->getName());
915 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
916 std::string
LookupName = Tag->getName().str();
923 std::string MacroName =
924 LookupName.empty() && Tag->getOuterLocStart().isMacroID()
926 Tag->getOuterLocStart(),
927 Tag->getASTContext().getSourceManager(),
LangOpts)
931 if (
LookupName.empty() && isa<clang::EnumDecl>(Tag) &&
932 (MacroName ==
"CF_OPTIONS" || MacroName ==
"NS_OPTIONS" ||
933 MacroName ==
"OBJC_OPTIONS" || MacroName ==
"SWIFT_OPTIONS")) {
941 if (
auto ParentTag = dyn_cast<TagDecl>(Tag->getDeclContext()))
943 auto Info = Reader->lookupTag(
LookupName, APINotesContext);
951 if (
auto Typedef = dyn_cast<TypedefNameDecl>(
D)) {
953 auto Info = Reader->lookupTypedef(Typedef->getName(), APINotesContext);
964 if (
auto EnumConstant = dyn_cast<EnumConstantDecl>(
D)) {
966 auto Info = Reader->lookupEnumConstant(EnumConstant->getName());
974 if (
auto ObjCContainer = dyn_cast<ObjCContainerDecl>(
D->
getDeclContext())) {
977 -> std::optional<api_notes::ContextID> {
978 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(ObjCContainer)) {
979 if (
auto Found = Reader->lookupObjCProtocolID(Protocol->getName()))
985 if (
auto Impl = dyn_cast<ObjCCategoryImplDecl>(ObjCContainer)) {
986 if (
auto Cat = Impl->getCategoryDecl())
987 ObjCContainer = Cat->getClassInterface();
992 if (
auto Category = dyn_cast<ObjCCategoryDecl>(ObjCContainer)) {
994 ObjCContainer =
Category->getClassInterface();
999 if (
auto Impl = dyn_cast<ObjCImplDecl>(ObjCContainer)) {
1000 if (Impl->getClassInterface())
1001 ObjCContainer = Impl->getClassInterface();
1003 return std::nullopt;
1006 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(ObjCContainer)) {
1007 if (
auto Found = Reader->lookupObjCClassID(
Class->getName()))
1010 return std::nullopt;
1013 return std::nullopt;
1017 if (
auto Method = dyn_cast<ObjCMethodDecl>(
D)) {
1019 if (
auto Context = GetContext(Reader)) {
1021 Selector Sel = Method->getSelector();
1026 for (
unsigned i = 0, n = Sel.
getNumArgs(); i != n; ++i)
1034 auto Info = Reader->lookupObjCMethod(*
Context, SelectorRef,
1035 Method->isInstanceMethod());
1042 if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
1044 if (
auto Context = GetContext(Reader)) {
1045 bool isInstanceProperty =
1046 (
Property->getPropertyAttributesAsWritten() &
1049 isInstanceProperty);
1059 if (
auto CXXMethod = dyn_cast<CXXMethodDecl>(
D)) {
1060 if (!isa<CXXConstructorDecl>(CXXMethod) &&
1061 !isa<CXXDestructorDecl>(CXXMethod) &&
1062 !isa<CXXConversionDecl>(CXXMethod) &&
1063 !CXXMethod->isOverloadedOperator()) {
1067 Reader->lookupCXXMethod(
Context->id, CXXMethod->getName());
1074 if (
auto Field = dyn_cast<FieldDecl>(
D)) {
1075 if (!Field->isUnnamedBitField() && !Field->isAnonymousStructOrUnion()) {
1078 auto Info = Reader->lookupField(
Context->id, Field->getName());
1085 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
1088 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 member of a struct/union/class.
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.
Describes API notes data for a C/C++ record field.
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
std::optional< std::string > SwiftConformance
The Swift protocol that this type should be automatically conformed to.
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