29enum class IsActive_t :
bool { Inactive, Active };
30enum class IsSubstitution_t :
bool { Original, Replacement };
32struct VersionedInfoMetadata {
35 unsigned IsActive : 1;
36 unsigned IsReplacement : 1;
38 VersionedInfoMetadata(VersionTuple Version, IsActive_t Active,
39 IsSubstitution_t Replacement)
40 : Version(Version), IsActive(Active == IsActive_t::Active),
41 IsReplacement(Replacement == IsSubstitution_t::Replacement) {}
57 VersionedInfoMetadata Metadata) {
58 if (!Metadata.IsActive)
68 return (QT.getTypePtr() != Original.getTypePtr()) ? std::optional(QT)
72 if (
auto Function = dyn_cast<FunctionDecl>(
D)) {
74 GetModified(
D,
Function->getReturnType(), Nullability)) {
78 *Modified, proto->getParamTypes(), proto->getExtProtoInfo()));
83 }
else if (
auto Method = dyn_cast<ObjCMethodDecl>(
D)) {
84 if (
auto Modified = GetModified(
D, Method->getReturnType(), Nullability)) {
85 Method->setReturnType(*Modified);
92 }
else if (
auto Value = dyn_cast<ValueDecl>(
D)) {
93 if (
auto Modified = GetModified(
D,
Value->
getType(), Nullability)) {
94 Value->setType(*Modified);
97 if (
auto Parm = dyn_cast<ParmVarDecl>(
D)) {
103 }
else if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
104 if (
auto Modified = GetModified(
D,
Property->getType(), Nullability)) {
117 void *mem = Ctx.
Allocate(String.size(),
alignof(
char *));
118 memcpy(mem, String.data(), String.size());
119 return StringRef(
static_cast<char *
>(mem), String.size());
131template <
typename A>
struct AttrKindFor {};
134 template <> struct AttrKindFor<X##Attr> { \
135 static const attr::Kind value = attr::X; \
137#include "clang/Basic/AttrList.inc"
145void handleAPINotedAttribute(
146 Sema &S,
Decl *
D,
bool IsAddition, VersionedInfoMetadata Metadata,
147 llvm::function_ref<A *()> CreateAttr,
149 if (Metadata.IsActive) {
150 auto Existing = GetExistingAttr(
D);
154 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
155 S.
Context, Metadata.Version, *Existing,
true);
163 if (
auto Attr = CreateAttr())
170 if (
auto Attr = CreateAttr()) {
171 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
173 Metadata.IsReplacement);
180 auto *Versioned = SwiftVersionedRemovalAttr::CreateImplicit(
181 S.
Context, Metadata.Version, AttrKindFor<A>::value,
182 Metadata.IsReplacement);
188void handleAPINotedAttribute(
Sema &S,
Decl *
D,
bool ShouldAddAttribute,
189 VersionedInfoMetadata Metadata,
190 llvm::function_ref<A *()> CreateAttr) {
191 handleAPINotedAttribute<A>(
192 S,
D, ShouldAddAttribute, Metadata, CreateAttr, [](
const Decl *
D) {
193 return llvm::find_if(
D->
attrs(),
194 [](
const Attr *Next) { return isa<A>(Next); });
201 bool ShouldAddAttribute,
202 VersionedInfoMetadata Metadata) {
205 handleAPINotedAttribute<A>(
206 S,
D, ShouldAddAttribute, Metadata,
209 return llvm::find_if(
D->
attrs(), [](
const Attr *Next) ->
bool {
210 return isa<CFReturnsRetainedAttr>(Next) ||
211 isa<CFReturnsNotRetainedAttr>(Next) ||
212 isa<NSReturnsRetainedAttr>(Next) ||
213 isa<NSReturnsNotRetainedAttr>(Next) ||
214 isa<CFAuditedTransferAttr>(Next);
220 Sema &S,
Decl *
D, VersionedInfoMetadata Metadata,
221 std::optional<api_notes::RetainCountConventionKind> Convention) {
224 switch (*Convention) {
225 case api_notes::RetainCountConventionKind::None:
226 if (isa<FunctionDecl>(
D)) {
227 handleAPINotedRetainCountAttribute<CFUnknownTransferAttr>(
228 S,
D,
true, Metadata);
230 handleAPINotedRetainCountAttribute<CFReturnsRetainedAttr>(
231 S,
D,
false, Metadata);
234 case api_notes::RetainCountConventionKind::CFReturnsRetained:
235 handleAPINotedRetainCountAttribute<CFReturnsRetainedAttr>(
236 S,
D,
true, Metadata);
238 case api_notes::RetainCountConventionKind::CFReturnsNotRetained:
239 handleAPINotedRetainCountAttribute<CFReturnsNotRetainedAttr>(
240 S,
D,
true, Metadata);
242 case api_notes::RetainCountConventionKind::NSReturnsRetained:
243 handleAPINotedRetainCountAttribute<NSReturnsRetainedAttr>(
244 S,
D,
true, Metadata);
246 case api_notes::RetainCountConventionKind::NSReturnsNotRetained:
247 handleAPINotedRetainCountAttribute<NSReturnsNotRetainedAttr>(
248 S,
D,
true, Metadata);
255 VersionedInfoMetadata Metadata) {
258 handleAPINotedAttribute<UnavailableAttr>(S,
D,
true, Metadata, [&] {
266 handleAPINotedAttribute<AvailabilityAttr>(
267 S,
D,
true, Metadata,
269 return new (S.
Context) AvailabilityAttr(
281 return llvm::find_if(
D->
attrs(), [](
const Attr *next) ->
bool {
282 if (const auto *AA = dyn_cast<AvailabilityAttr>(next))
283 if (const auto *II = AA->getPlatform())
284 return II->isStr(
"swift");
292 handleAPINotedAttribute<SwiftPrivateAttr>(
293 S,
D, *SwiftPrivate, Metadata, [&] {
301 handleAPINotedAttribute<SwiftNameAttr>(
302 S,
D,
true, Metadata, [&]() -> SwiftNameAttr * {
307 AP.create(&
C.Idents.get(
"swift_name"),
SourceRange(),
nullptr,
309 ParsedAttr::Form::GNU());
324 VersionedInfoMetadata Metadata) {
327 handleAPINotedAttribute<SwiftBridgeAttr>(
328 S,
D, !SwiftBridge->empty(), Metadata, [&] {
329 return new (S.Context)
330 SwiftBridgeAttr(S.Context, getPlaceholderAttrInfo(),
331 ASTAllocateString(S.Context, *SwiftBridge));
337 handleAPINotedAttribute<NSErrorDomainAttr>(
338 S,
D, !NSErrorDomain->empty(), Metadata, [&] {
339 return new (S.Context)
340 NSErrorDomainAttr(S.Context, getPlaceholderAttrInfo(),
341 &S.Context.Idents.get(*NSErrorDomain));
357 S.
Diag(
Loc, diag::err_incompatible_replacement_type)
358 << ReplacementType << OrigType;
368 VersionedInfoMetadata Metadata) {
370 if (Metadata.IsActive && !Info.
getType().empty() &&
379 if (
auto Var = dyn_cast<VarDecl>(
D)) {
381 if (isa<ParmVarDecl>(Var)) {
392 }
else if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
398 llvm_unreachable(
"API notes allowed a type on an unknown declaration");
414 VersionedInfoMetadata Metadata) {
417 handleAPINotedAttribute<NoEscapeAttr>(S,
D, *NoEscape, Metadata, [&] {
422 handleAPINotedAttribute<LifetimeBoundAttr>(
423 S,
D, *Lifetimebound, Metadata, [&] {
440 VersionedInfoMetadata metadata) {
449 VersionedInfoMetadata metadata) {
458 VersionedInfoMetadata Metadata) {
464 handleAPINotedAttribute<SwiftImportPropertyAsAccessorsAttr>(
465 S,
D, *AsAccessors, Metadata, [&] {
466 return new (S.
Context) SwiftImportPropertyAsAccessorsAttr(
473typedef llvm::PointerUnion<FunctionDecl *, ObjCMethodDecl *> FunctionOrMethod;
479 VersionedInfoMetadata Metadata) {
485 MD = cast<ObjCMethodDecl *>(AnyFunc);
489 assert((FD || MD) &&
"Expecting Function or ObjCMethod");
498 bool AnyTypeChanged =
false;
499 for (
unsigned I = 0; I != NumParams; ++I) {
503 if (I < Info.
Params.size())
511 AnyTypeChanged =
true;
521 if (Metadata.IsActive && !Info.
ResultType.empty() &&
531 auto ResultTypeInfo =
538 OverriddenResultType = ResultType;
539 AnyTypeChanged =
true;
546 if (FD && AnyTypeChanged) {
548 if (OverriddenResultType.
isNull())
549 OverriddenResultType = fnProtoType->getReturnType();
553 ParamTypes.push_back(Param->getType());
556 fnProtoType->getExtProtoInfo()));
557 }
else if (!OverriddenResultType.
isNull()) {
560 OverriddenResultType, FnNoProtoType->getExtInfo()));
576 VersionedInfoMetadata Metadata) {
577 if (Info.
This && Info.
This->isLifetimebound() &&
579 auto MethodType = Method->
getType();
598 VersionedInfoMetadata Metadata) {
607 VersionedInfoMetadata Metadata) {
616 VersionedInfoMetadata Metadata) {
619 handleAPINotedAttribute<ObjCDesignatedInitializerAttr>(
620 S,
D,
true, Metadata, [&] {
622 IFace->setHasDesignatedInitializers();
624 return new (S.
Context) ObjCDesignatedInitializerAttr(
636 VersionedInfoMetadata Metadata) {
638 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"import_" + ImportAs.value()));
641 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"retain:" + RetainOp.value()));
645 SwiftAttrAttr::Create(S.
Context,
"release:" + ReleaseOp.value()));
649 SwiftAttrAttr::Create(S.
Context,
"conforms_to:" + ConformsTo.value()));
658 *Escapable ?
"Escapable" :
"~Escapable"));
663 bool ShouldAddAttribute = (*Extensibility != EnumExtensibilityKind::None);
664 handleAPINotedAttribute<EnumExtensibilityAttr>(
665 S,
D, ShouldAddAttribute, Metadata, [&] {
666 EnumExtensibilityAttr::Kind kind;
667 switch (*Extensibility) {
668 case EnumExtensibilityKind::None:
669 llvm_unreachable(
"remove only");
670 case EnumExtensibilityKind::Open:
671 kind = EnumExtensibilityAttr::Open;
673 case EnumExtensibilityKind::Closed:
674 kind = EnumExtensibilityAttr::Closed;
683 handleAPINotedAttribute<FlagEnumAttr>(S,
D, *FlagEnum, Metadata, [&] {
696 VersionedInfoMetadata Metadata) {
701 handleAPINotedAttribute<SwiftNewTypeAttr>(
702 S,
D, *SwiftWrapper != SwiftWrapperKind::None, Metadata, [&] {
703 SwiftNewTypeAttr::NewtypeKind Kind;
704 switch (*SwiftWrapper) {
705 case SwiftWrapperKind::None:
706 llvm_unreachable(
"Shouldn't build an attribute");
708 case SwiftWrapperKind::Struct:
709 Kind = SwiftNewTypeAttr::NK_Struct;
712 case SwiftWrapperKind::Enum:
713 Kind = SwiftNewTypeAttr::NK_Enum;
718 AttributeCommonInfo::AT_SwiftNewType,
721 return new (S.
Context) SwiftNewTypeAttr(S.
Context, SyntaxInfo, Kind);
733 VersionedInfoMetadata Metadata) {
742 VersionedInfoMetadata Metadata) {
744 handleAPINotedAttribute<SwiftImportAsNonGenericAttr>(
745 S,
D, *AsNonGeneric, Metadata, [&] {
752 handleAPINotedAttribute<SwiftObjCMembersAttr>(
753 S,
D, *ObjcMembers, Metadata, [&] {
772template <
typename SpecificInfo>
782 VersionTuple SelectedVersion;
783 SpecificInfo SelectedInfoSlice;
784 std::tie(SelectedVersion, SelectedInfoSlice) = Info[*Info.
getSelected()];
785 if (SelectedVersion.empty())
787 if (SelectedInfoSlice.SwiftName.empty())
791 for (
const auto &VersionAndInfoSlice : Info) {
792 if (!VersionAndInfoSlice.first.empty())
794 if (!VersionAndInfoSlice.second.SwiftName.empty())
799 VersionedInfoMetadata DummyFutureMetadata(
800 SelectedVersion, IsActive_t::Inactive, IsSubstitution_t::Replacement);
801 handleAPINotedAttribute<SwiftNameAttr>(
802 S,
D,
false, DummyFutureMetadata, []() -> SwiftNameAttr * {
803 llvm_unreachable(
"should not try to add an attribute here");
810template <
typename SpecificDecl,
typename SpecificInfo>
812 Sema &S, SpecificDecl *
D,
819 VersionTuple Version;
820 SpecificInfo InfoSlice;
821 for (
unsigned i = 0, e = Info.
size(); i != e; ++i) {
822 std::tie(Version, InfoSlice) = Info[i];
823 auto Active = (i == Selected) ? IsActive_t::Active : IsActive_t::Inactive;
824 auto Replacement = IsSubstitution_t::Original;
825 if (Active == IsActive_t::Inactive && Version.empty()) {
826 Replacement = IsSubstitution_t::Replacement;
827 Version = Info[Selected].first;
830 VersionedInfoMetadata(Version, Active, Replacement));
834static std::optional<api_notes::Context>
836 if (
auto NamespaceContext = dyn_cast<NamespaceDecl>(DC)) {
837 for (
auto Reader : APINotes.
findAPINotes(NamespaceContext->getLocation())) {
839 std::stack<NamespaceDecl *> NamespaceStack;
841 for (
auto CurrentNamespace = NamespaceContext; CurrentNamespace;
843 dyn_cast<NamespaceDecl>(CurrentNamespace->getParent())) {
844 if (!CurrentNamespace->isInlineNamespace())
845 NamespaceStack.push(CurrentNamespace);
848 std::optional<api_notes::ContextID> NamespaceID;
849 while (!NamespaceStack.empty()) {
850 auto CurrentNamespace = NamespaceStack.top();
851 NamespaceStack.pop();
853 Reader->lookupNamespaceID(CurrentNamespace->getName(), NamespaceID);
859 api_notes::ContextKind::Namespace);
865static std::optional<api_notes::Context>
867 assert(DC &&
"tag context must not be null");
870 std::stack<TagDecl *> TagStack;
872 for (
auto CurrentTag = DC; CurrentTag;
873 CurrentTag = dyn_cast<TagDecl>(CurrentTag->getParent()))
874 TagStack.push(CurrentTag);
876 assert(!TagStack.empty());
877 std::optional<api_notes::Context> Ctx =
879 while (!TagStack.empty()) {
880 auto CurrentTag = TagStack.top();
882 auto CtxID = Reader->lookupTagID(CurrentTag->getName(), Ctx);
900 if (DC->isFileContext() || DC->isNamespace() || DC->isExternCContext() ||
901 DC->isExternCXXContext()) {
902 std::optional<api_notes::Context> APINotesContext =
905 if (
auto VD = dyn_cast<VarDecl>(
D)) {
908 Reader->lookupGlobalVariable(VD->getName(), APINotesContext);
916 if (
auto FD = dyn_cast<FunctionDecl>(
D)) {
917 if (FD->getDeclName().isIdentifier()) {
920 Reader->lookupGlobalFunction(FD->getName(), APINotesContext);
929 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(
D)) {
931 auto Info = Reader->lookupObjCClassInfo(
Class->getName());
939 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(
D)) {
941 auto Info = Reader->lookupObjCProtocolInfo(Protocol->getName());
949 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
955 if (
auto typedefName = Tag->getTypedefNameForAnonDecl())
965 std::string MacroName =
966 LookupName.empty() && Tag->getOuterLocStart().isMacroID()
968 Tag->getOuterLocStart(),
969 Tag->getASTContext().getSourceManager(),
LangOpts)
973 if (
LookupName.empty() && isa<clang::EnumDecl>(Tag) &&
974 (MacroName ==
"CF_OPTIONS" || MacroName ==
"NS_OPTIONS" ||
975 MacroName ==
"OBJC_OPTIONS" || MacroName ==
"SWIFT_OPTIONS")) {
983 if (
auto ParentTag = dyn_cast<TagDecl>(Tag->getDeclContext()))
985 auto Info = Reader->lookupTag(
LookupName, APINotesContext);
993 if (
auto Typedef = dyn_cast<TypedefNameDecl>(
D)) {
995 auto Info = Reader->lookupTypedef(Typedef->getName(), APINotesContext);
1004 if (DC->getRedeclContext()->isFileContext() ||
1005 DC->getRedeclContext()->isExternCContext()) {
1006 if (
auto EnumConstant = dyn_cast<EnumConstantDecl>(
D)) {
1008 auto Info = Reader->lookupEnumConstant(EnumConstant->getName());
1016 if (
auto ObjCContainer = dyn_cast<ObjCContainerDecl>(DC)) {
1019 -> std::optional<api_notes::ContextID> {
1020 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(ObjCContainer)) {
1021 if (
auto Found = Reader->lookupObjCProtocolID(Protocol->getName()))
1024 return std::nullopt;
1027 if (
auto Impl = dyn_cast<ObjCCategoryImplDecl>(ObjCContainer)) {
1028 if (
auto Cat = Impl->getCategoryDecl())
1029 ObjCContainer = Cat->getClassInterface();
1031 return std::nullopt;
1034 if (
auto Category = dyn_cast<ObjCCategoryDecl>(ObjCContainer)) {
1036 ObjCContainer =
Category->getClassInterface();
1038 return std::nullopt;
1041 if (
auto Impl = dyn_cast<ObjCImplDecl>(ObjCContainer)) {
1042 if (Impl->getClassInterface())
1043 ObjCContainer = Impl->getClassInterface();
1045 return std::nullopt;
1048 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(ObjCContainer)) {
1049 if (
auto Found = Reader->lookupObjCClassID(
Class->getName()))
1052 return std::nullopt;
1055 return std::nullopt;
1059 if (
auto Method = dyn_cast<ObjCMethodDecl>(
D)) {
1061 if (
auto Context = GetContext(Reader)) {
1063 Selector Sel = Method->getSelector();
1068 for (
unsigned i = 0, n = Sel.
getNumArgs(); i != n; ++i)
1076 auto Info = Reader->lookupObjCMethod(*
Context, SelectorRef,
1077 Method->isInstanceMethod());
1084 if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
1086 if (
auto Context = GetContext(Reader)) {
1087 bool isInstanceProperty =
1088 (
Property->getPropertyAttributesAsWritten() &
1091 isInstanceProperty);
1100 if (
auto TagContext = dyn_cast<TagDecl>(DC)) {
1101 if (
auto CXXMethod = dyn_cast<CXXMethodDecl>(
D)) {
1102 if (!isa<CXXConstructorDecl>(CXXMethod) &&
1103 !isa<CXXDestructorDecl>(CXXMethod) &&
1104 !isa<CXXConversionDecl>(CXXMethod) &&
1105 !CXXMethod->isOverloadedOperator()) {
1109 Reader->lookupCXXMethod(
Context->id, CXXMethod->getName());
1116 if (
auto Field = dyn_cast<FieldDecl>(
D)) {
1117 if (!Field->isUnnamedBitField() && !Field->isAnonymousStructOrUnion()) {
1120 auto Info = Reader->lookupField(
Context->id, Field->getName());
1127 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
1130 auto Info = Reader->lookupTag(Tag->getName(),
Context);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
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.
Defines the clang::TypeLoc interface and its subclasses.
__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 getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
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...
Type source information for an attributed type.
void setAttr(const Attr *A)
An attributed type is a type to which a type attribute has been applied.
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...
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()
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
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.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
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.
std::optional< ParamInfo > This
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::string SwiftReturnOwnership
Ownership convention for return value.
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< bool > isLifetimebound() 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< bool > isSwiftEscapable() 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.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD)
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