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) {}
56 VersionedInfoMetadata metadata) {
57 if (typeString.empty())
64 auto *typeAttr = SwiftTypeAttr::CreateImplicit(S.
Context, typeString);
65 auto *versioned = SwiftVersionedAdditionAttr::CreateImplicit(
66 S.
Context, metadata.Version, typeAttr, metadata.IsReplacement);
67 decl->addAttr(versioned);
69 if (!metadata.IsActive)
77 VersionedInfoMetadata metadata) {
81 SwiftNullabilityAttr::Kind attrNullabilityKind;
82 switch (nullability) {
83 case NullabilityKind::NonNull:
84 attrNullabilityKind = SwiftNullabilityAttr::Kind::NonNull;
86 case NullabilityKind::Nullable:
87 attrNullabilityKind = SwiftNullabilityAttr::Kind::Nullable;
89 case NullabilityKind::Unspecified:
90 attrNullabilityKind = SwiftNullabilityAttr::Kind::Unspecified;
92 case NullabilityKind::NullableResult:
93 attrNullabilityKind = SwiftNullabilityAttr::Kind::NullableResult;
96 auto *nullabilityAttr =
97 SwiftNullabilityAttr::CreateImplicit(S.
Context, attrNullabilityKind);
98 auto *versioned = SwiftVersionedAdditionAttr::CreateImplicit(
99 S.
Context, metadata.Version, nullabilityAttr, metadata.IsReplacement);
100 decl->addAttr(versioned);
103 if (!metadata.IsActive)
112 void *mem = Ctx.
Allocate(String.size(),
alignof(
char *));
113 memcpy(mem, String.data(), String.size());
114 return StringRef(
static_cast<char *
>(mem), String.size());
126template <
typename A>
struct AttrKindFor {};
129 template <> struct AttrKindFor<X##Attr> { \
130 static const attr::Kind value = attr::X; \
132#include "clang/Basic/AttrList.inc"
140void handleAPINotedAttribute(
141 Sema &S,
Decl *
D,
bool IsAddition, VersionedInfoMetadata Metadata,
142 llvm::function_ref<A *()> CreateAttr,
144 if (Metadata.IsActive) {
145 auto Existing = GetExistingAttr(
D);
149 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
150 S.
Context, Metadata.Version, *Existing,
true);
158 if (
auto Attr = CreateAttr())
165 if (
auto Attr = CreateAttr()) {
166 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
168 Metadata.IsReplacement);
175 auto *Versioned = SwiftVersionedRemovalAttr::CreateImplicit(
176 S.
Context, Metadata.Version, AttrKindFor<A>::value,
177 Metadata.IsReplacement);
183void handleAPINotedAttribute(
Sema &S,
Decl *
D,
bool ShouldAddAttribute,
184 VersionedInfoMetadata Metadata,
185 llvm::function_ref<A *()> CreateAttr) {
186 handleAPINotedAttribute<A>(
187 S,
D, ShouldAddAttribute, Metadata, CreateAttr, [](
const Decl *
D) {
188 return llvm::find_if(
D->
attrs(),
189 [](
const Attr *Next) { return isa<A>(Next); });
196 bool ShouldAddAttribute,
197 VersionedInfoMetadata Metadata) {
200 handleAPINotedAttribute<A>(
201 S,
D, ShouldAddAttribute, Metadata,
204 return llvm::find_if(
D->
attrs(), [](
const Attr *Next) ->
bool {
205 return isa<CFReturnsRetainedAttr>(Next) ||
206 isa<CFReturnsNotRetainedAttr>(Next) ||
207 isa<NSReturnsRetainedAttr>(Next) ||
208 isa<NSReturnsNotRetainedAttr>(Next) ||
209 isa<CFAuditedTransferAttr>(Next);
215 Sema &S,
Decl *
D, VersionedInfoMetadata Metadata,
216 std::optional<api_notes::RetainCountConventionKind> Convention) {
219 switch (*Convention) {
220 case api_notes::RetainCountConventionKind::None:
221 if (isa<FunctionDecl>(
D)) {
222 handleAPINotedRetainCountAttribute<CFUnknownTransferAttr>(
223 S,
D,
true, Metadata);
225 handleAPINotedRetainCountAttribute<CFReturnsRetainedAttr>(
226 S,
D,
false, Metadata);
229 case api_notes::RetainCountConventionKind::CFReturnsRetained:
230 handleAPINotedRetainCountAttribute<CFReturnsRetainedAttr>(
231 S,
D,
true, Metadata);
233 case api_notes::RetainCountConventionKind::CFReturnsNotRetained:
234 handleAPINotedRetainCountAttribute<CFReturnsNotRetainedAttr>(
235 S,
D,
true, Metadata);
237 case api_notes::RetainCountConventionKind::NSReturnsRetained:
238 handleAPINotedRetainCountAttribute<NSReturnsRetainedAttr>(
239 S,
D,
true, Metadata);
241 case api_notes::RetainCountConventionKind::NSReturnsNotRetained:
242 handleAPINotedRetainCountAttribute<NSReturnsNotRetainedAttr>(
243 S,
D,
true, Metadata);
250 VersionedInfoMetadata Metadata) {
253 handleAPINotedAttribute<UnavailableAttr>(S,
D,
true, Metadata, [&] {
261 handleAPINotedAttribute<AvailabilityAttr>(
262 S,
D,
true, Metadata,
264 return new (S.
Context) AvailabilityAttr(
276 return llvm::find_if(
D->
attrs(), [](
const Attr *next) ->
bool {
277 if (const auto *AA = dyn_cast<AvailabilityAttr>(next))
278 if (const auto *II = AA->getPlatform())
279 return II->isStr(
"swift");
287 handleAPINotedAttribute<SwiftPrivateAttr>(
288 S,
D, *SwiftPrivate, Metadata, [&] {
296 handleAPINotedAttribute<SwiftNameAttr>(
297 S,
D,
true, Metadata, [&]() -> SwiftNameAttr * {
303 nullptr,
nullptr,
nullptr, ParsedAttr::Form::GNU());
318 VersionedInfoMetadata Metadata) {
321 handleAPINotedAttribute<SwiftBridgeAttr>(
322 S,
D, !SwiftBridge->empty(), Metadata, [&] {
323 return new (S.Context)
324 SwiftBridgeAttr(S.Context, getPlaceholderAttrInfo(),
325 ASTAllocateString(S.Context, *SwiftBridge));
331 handleAPINotedAttribute<NSErrorDomainAttr>(
332 S,
D, !NSErrorDomain->empty(), Metadata, [&] {
333 return new (S.Context)
334 NSErrorDomainAttr(S.Context, getPlaceholderAttrInfo(),
335 &S.Context.Idents.get(*NSErrorDomain));
341 SwiftAttrAttr::Create(S.
Context,
"conforms_to:" + ConformsTo.value()));
355 S.
Diag(
Loc, diag::err_incompatible_replacement_type)
356 << ReplacementType << OrigType;
370 if (
auto Var = dyn_cast<VarDecl>(
D)) {
372 if (isa<ParmVarDecl>(Var)) {
379 Var->getType(),
Type)) {
383 }
else if (
auto property = dyn_cast<ObjCPropertyDecl>(
D)) {
385 property->getType(),
Type)) {
389 llvm_unreachable(
"API notes allowed a type on an unknown declaration");
403 return (QT.getTypePtr() != Original.getTypePtr()) ? std::optional(QT)
407 if (
auto Function = dyn_cast<FunctionDecl>(
D)) {
409 GetModified(
D,
Function->getReturnType(), Nullability)) {
413 *Modified, proto->getParamTypes(), proto->getExtProtoInfo()));
418 }
else if (
auto Method = dyn_cast<ObjCMethodDecl>(
D)) {
419 if (
auto Modified = GetModified(
D,
Method->getReturnType(), Nullability)) {
420 Method->setReturnType(*Modified);
427 }
else if (
auto Value = dyn_cast<ValueDecl>(
D)) {
428 if (
auto Modified = GetModified(
D,
Value->
getType(), Nullability)) {
429 Value->setType(*Modified);
432 if (
auto Parm = dyn_cast<ParmVarDecl>(
D)) {
438 }
else if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
439 if (
auto Modified = GetModified(
D,
Property->getType(), Nullability)) {
453 VersionedInfoMetadata Metadata) {
469 VersionedInfoMetadata Metadata) {
472 handleAPINotedAttribute<NoEscapeAttr>(S,
D, *NoEscape, Metadata, [&] {
477 handleAPINotedAttribute<LifetimeBoundAttr>(
478 S,
D, *Lifetimebound, Metadata, [&] {
495 VersionedInfoMetadata metadata) {
504 VersionedInfoMetadata metadata) {
513 VersionedInfoMetadata Metadata) {
519 handleAPINotedAttribute<SwiftImportPropertyAsAccessorsAttr>(
520 S,
D, *AsAccessors, Metadata, [&] {
521 return new (S.
Context) SwiftImportPropertyAsAccessorsAttr(
528typedef llvm::PointerUnion<FunctionDecl *, ObjCMethodDecl *> FunctionOrMethod;
534 VersionedInfoMetadata Metadata) {
540 MD = cast<ObjCMethodDecl *>(AnyFunc);
544 assert((FD || MD) &&
"Expecting Function or ObjCMethod");
553 bool AnyTypeChanged =
false;
554 for (
unsigned I = 0; I != NumParams; ++I) {
558 if (I < Info.
Params.size())
566 AnyTypeChanged =
true;
576 if (Metadata.IsActive && !Info.
ResultType.empty() &&
586 auto ResultTypeInfo =
593 OverriddenResultType = ResultType;
594 AnyTypeChanged =
true;
601 if (FD && AnyTypeChanged) {
603 if (OverriddenResultType.
isNull())
604 OverriddenResultType = fnProtoType->getReturnType();
608 ParamTypes.push_back(Param->getType());
611 fnProtoType->getExtProtoInfo()));
612 }
else if (!OverriddenResultType.
isNull()) {
615 OverriddenResultType, FnNoProtoType->getExtInfo()));
631 VersionedInfoMetadata Metadata) {
632 if (Info.
This && Info.
This->isLifetimebound() &&
634 auto MethodType =
Method->getType();
653 VersionedInfoMetadata Metadata) {
662 VersionedInfoMetadata Metadata) {
671 VersionedInfoMetadata Metadata) {
674 handleAPINotedAttribute<ObjCDesignatedInitializerAttr>(
675 S,
D,
true, Metadata, [&] {
677 IFace->setHasDesignatedInitializers();
679 return new (S.
Context) ObjCDesignatedInitializerAttr(
691 VersionedInfoMetadata Metadata) {
693 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"import_" + ImportAs.value()));
696 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"retain:" + RetainOp.value()));
700 SwiftAttrAttr::Create(S.
Context,
"release:" + ReleaseOp.value()));
703 SwiftAttrAttr::Create(S.
Context,
"destroy:" + DestroyOp.value()));
706 S.
Context,
"returned_as_" + DefaultOwnership.value() +
"_by_default"));
715 *Escapable ?
"Escapable" :
"~Escapable"));
720 bool ShouldAddAttribute = (*Extensibility != EnumExtensibilityKind::None);
721 handleAPINotedAttribute<EnumExtensibilityAttr>(
722 S,
D, ShouldAddAttribute, Metadata, [&] {
723 EnumExtensibilityAttr::Kind kind;
724 switch (*Extensibility) {
725 case EnumExtensibilityKind::None:
726 llvm_unreachable(
"remove only");
727 case EnumExtensibilityKind::Open:
728 kind = EnumExtensibilityAttr::Open;
730 case EnumExtensibilityKind::Closed:
731 kind = EnumExtensibilityAttr::Closed;
740 handleAPINotedAttribute<FlagEnumAttr>(S,
D, *FlagEnum, Metadata, [&] {
753 VersionedInfoMetadata Metadata) {
758 handleAPINotedAttribute<SwiftNewTypeAttr>(
759 S,
D, *SwiftWrapper != SwiftWrapperKind::None, Metadata, [&] {
760 SwiftNewTypeAttr::NewtypeKind Kind;
761 switch (*SwiftWrapper) {
762 case SwiftWrapperKind::None:
763 llvm_unreachable(
"Shouldn't build an attribute");
765 case SwiftWrapperKind::Struct:
766 Kind = SwiftNewTypeAttr::NK_Struct;
769 case SwiftWrapperKind::Enum:
770 Kind = SwiftNewTypeAttr::NK_Enum;
775 AttributeCommonInfo::AT_SwiftNewType,
778 return new (S.
Context) SwiftNewTypeAttr(S.
Context, SyntaxInfo, Kind);
790 VersionedInfoMetadata Metadata) {
799 VersionedInfoMetadata Metadata) {
801 handleAPINotedAttribute<SwiftImportAsNonGenericAttr>(
802 S,
D, *AsNonGeneric, Metadata, [&] {
809 handleAPINotedAttribute<SwiftObjCMembersAttr>(
810 S,
D, *ObjcMembers, Metadata, [&] {
829template <
typename SpecificInfo>
839 VersionTuple SelectedVersion;
840 SpecificInfo SelectedInfoSlice;
841 std::tie(SelectedVersion, SelectedInfoSlice) = Info[*Info.
getSelected()];
842 if (SelectedVersion.empty())
844 if (SelectedInfoSlice.SwiftName.empty())
848 for (
const auto &VersionAndInfoSlice : Info) {
849 if (!VersionAndInfoSlice.first.empty())
851 if (!VersionAndInfoSlice.second.SwiftName.empty())
856 VersionedInfoMetadata DummyFutureMetadata(
857 SelectedVersion, IsActive_t::Inactive, IsSubstitution_t::Replacement);
858 handleAPINotedAttribute<SwiftNameAttr>(
859 S,
D,
false, DummyFutureMetadata, []() -> SwiftNameAttr * {
860 llvm_unreachable(
"should not try to add an attribute here");
867template <
typename SpecificDecl,
typename SpecificInfo>
869 Sema &S, SpecificDecl *
D,
877 VersionTuple Version;
878 SpecificInfo InfoSlice;
879 for (
unsigned i = 0, e = Info.
size(); i != e; ++i) {
880 std::tie(Version, InfoSlice) = Info[i];
881 auto Active = (i == Selected) ? IsActive_t::Active : IsActive_t::Inactive;
882 auto Replacement = IsSubstitution_t::Original;
888 Active = IsActive_t::Inactive;
889 Replacement = IsSubstitution_t::Original;
890 }
else if (Active == IsActive_t::Inactive && Version.empty()) {
891 Replacement = IsSubstitution_t::Replacement;
892 Version = Info[Selected].first;
896 VersionedInfoMetadata(Version, Active, Replacement));
900static std::optional<api_notes::Context>
902 if (
auto NamespaceContext = dyn_cast<NamespaceDecl>(DC)) {
903 for (
auto Reader : APINotes.
findAPINotes(NamespaceContext->getLocation())) {
905 std::stack<NamespaceDecl *> NamespaceStack;
907 for (
auto CurrentNamespace = NamespaceContext; CurrentNamespace;
909 dyn_cast<NamespaceDecl>(CurrentNamespace->getParent())) {
910 if (!CurrentNamespace->isInlineNamespace())
911 NamespaceStack.push(CurrentNamespace);
914 std::optional<api_notes::ContextID> NamespaceID;
915 while (!NamespaceStack.empty()) {
916 auto CurrentNamespace = NamespaceStack.top();
917 NamespaceStack.pop();
919 Reader->lookupNamespaceID(CurrentNamespace->getName(), NamespaceID);
931static std::optional<api_notes::Context>
933 assert(DC &&
"tag context must not be null");
936 std::stack<TagDecl *> TagStack;
938 for (
auto CurrentTag = DC; CurrentTag;
939 CurrentTag = dyn_cast<TagDecl>(CurrentTag->getParent()))
940 TagStack.push(CurrentTag);
942 assert(!TagStack.empty());
943 std::optional<api_notes::Context> Ctx =
945 while (!TagStack.empty()) {
946 auto CurrentTag = TagStack.top();
948 auto CtxID = Reader->lookupTagID(CurrentTag->getName(), Ctx);
966 if (DC->isFileContext() || DC->isNamespace() || DC->isExternCContext() ||
967 DC->isExternCXXContext()) {
968 std::optional<api_notes::Context> APINotesContext =
971 if (
auto VD = dyn_cast<VarDecl>(
D)) {
974 Reader->lookupGlobalVariable(VD->getName(), APINotesContext);
982 if (
auto FD = dyn_cast<FunctionDecl>(
D)) {
983 if (FD->getDeclName().isIdentifier()) {
986 Reader->lookupGlobalFunction(FD->getName(), APINotesContext);
995 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(
D)) {
997 auto Info = Reader->lookupObjCClassInfo(
Class->getName());
1005 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(
D)) {
1007 auto Info = Reader->lookupObjCProtocolInfo(Protocol->getName());
1015 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
1021 if (
auto typedefName = Tag->getTypedefNameForAnonDecl())
1031 std::string MacroName =
1032 LookupName.empty() && Tag->getOuterLocStart().isMacroID()
1034 Tag->getOuterLocStart(),
1035 Tag->getASTContext().getSourceManager(),
LangOpts)
1039 if (
LookupName.empty() && isa<clang::EnumDecl>(Tag) &&
1040 (MacroName ==
"CF_OPTIONS" || MacroName ==
"NS_OPTIONS" ||
1041 MacroName ==
"OBJC_OPTIONS" || MacroName ==
"SWIFT_OPTIONS")) {
1049 if (
auto ParentTag = dyn_cast<TagDecl>(Tag->getDeclContext()))
1051 auto Info = Reader->lookupTag(
LookupName, APINotesContext);
1059 if (
auto Typedef = dyn_cast<TypedefNameDecl>(
D)) {
1061 auto Info = Reader->lookupTypedef(
Typedef->getName(), APINotesContext);
1070 if (DC->getRedeclContext()->isFileContext() ||
1071 DC->getRedeclContext()->isExternCContext()) {
1072 if (
auto EnumConstant = dyn_cast<EnumConstantDecl>(
D)) {
1074 auto Info = Reader->lookupEnumConstant(EnumConstant->getName());
1082 if (
auto ObjCContainer = dyn_cast<ObjCContainerDecl>(DC)) {
1085 -> std::optional<api_notes::ContextID> {
1086 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(ObjCContainer)) {
1087 if (
auto Found = Reader->lookupObjCProtocolID(Protocol->getName()))
1090 return std::nullopt;
1093 if (
auto Impl = dyn_cast<ObjCCategoryImplDecl>(ObjCContainer)) {
1094 if (
auto Cat = Impl->getCategoryDecl())
1095 ObjCContainer = Cat->getClassInterface();
1097 return std::nullopt;
1100 if (
auto Category = dyn_cast<ObjCCategoryDecl>(ObjCContainer)) {
1102 ObjCContainer =
Category->getClassInterface();
1104 return std::nullopt;
1107 if (
auto Impl = dyn_cast<ObjCImplDecl>(ObjCContainer)) {
1108 if (Impl->getClassInterface())
1109 ObjCContainer = Impl->getClassInterface();
1111 return std::nullopt;
1114 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(ObjCContainer)) {
1115 if (
auto Found = Reader->lookupObjCClassID(
Class->getName()))
1118 return std::nullopt;
1121 return std::nullopt;
1125 if (
auto Method = dyn_cast<ObjCMethodDecl>(
D)) {
1127 if (
auto Context = GetContext(Reader)) {
1134 for (
unsigned i = 0, n = Sel.
getNumArgs(); i != n; ++i)
1142 auto Info = Reader->lookupObjCMethod(*
Context, SelectorRef,
1143 Method->isInstanceMethod());
1150 if (
auto Property = dyn_cast<ObjCPropertyDecl>(
D)) {
1152 if (
auto Context = GetContext(Reader)) {
1153 bool isInstanceProperty =
1154 (
Property->getPropertyAttributesAsWritten() &
1157 isInstanceProperty);
1166 if (
auto TagContext = dyn_cast<TagDecl>(DC)) {
1167 if (
auto CXXMethod = dyn_cast<CXXMethodDecl>(
D)) {
1168 if (!isa<CXXConstructorDecl>(CXXMethod) &&
1169 !isa<CXXDestructorDecl>(CXXMethod) &&
1170 !isa<CXXConversionDecl>(CXXMethod) &&
1171 !CXXMethod->isOverloadedOperator()) {
1175 Reader->lookupCXXMethod(
Context->id, CXXMethod->getName());
1182 if (
auto Field = dyn_cast<FieldDecl>(
D)) {
1183 if (!Field->isUnnamedBitField() && !Field->isAnonymousStructOrUnion()) {
1186 auto Info = Reader->lookupField(
Context->id, Field->getName());
1193 if (
auto Tag = dyn_cast<TagDecl>(
D)) {
1196 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 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 applyAPINotesType(Sema &S, Decl *decl, StringRef typeString, VersionedInfoMetadata metadata)
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 applyNullability(Sema &S, Decl *decl, NullabilityKind nullability, VersionedInfoMetadata metadata)
Apply nullability to the given declaration.
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()
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.
bool captureSwiftVersionIndependentAPINotes()
Whether APINotes should be gathered for all applicable Swift language versions, without being applied...
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.
void ApplyNullability(Decl *D, NullabilityKind Nullability)
Apply the 'Nullability:' annotation to the specified declaration.
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 ApplyAPINotesType(Decl *D, StringRef TypeString)
Apply the 'Type:' annotation to the specified 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.
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.
std::optional< std::string > getSwiftConformance() const
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< std::string > SwiftDefaultOwnership
std::optional< EnumExtensibilityKind > EnumExtensibility
std::optional< std::string > SwiftDestroyOp
std::optional< bool > isFlagEnum() const
std::optional< bool > isSwiftCopyable() const
std::optional< bool > isSwiftEscapable() 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.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
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