30enum class IsActive_t :
bool { Inactive, Active };
31enum class IsSubstitution_t :
bool { Original, Replacement };
33struct VersionedInfoMetadata {
36 unsigned IsActive : 1;
37 unsigned IsReplacement : 1;
39 VersionedInfoMetadata(VersionTuple Version, IsActive_t Active,
40 IsSubstitution_t Replacement)
41 : Version(Version), IsActive(Active == IsActive_t::Active),
42 IsReplacement(Replacement == IsSubstitution_t::Replacement) {}
57 VersionedInfoMetadata metadata) {
58 if (typeString.empty())
65 auto *typeAttr = SwiftTypeAttr::CreateImplicit(S.
Context, typeString);
66 auto *versioned = SwiftVersionedAdditionAttr::CreateImplicit(
67 S.
Context, metadata.Version, typeAttr, metadata.IsReplacement);
68 decl->addAttr(versioned);
70 if (!metadata.IsActive)
78 VersionedInfoMetadata metadata) {
82 SwiftNullabilityAttr::Kind attrNullabilityKind;
83 switch (nullability) {
85 attrNullabilityKind = SwiftNullabilityAttr::Kind::NonNull;
88 attrNullabilityKind = SwiftNullabilityAttr::Kind::Nullable;
91 attrNullabilityKind = SwiftNullabilityAttr::Kind::Unspecified;
94 attrNullabilityKind = SwiftNullabilityAttr::Kind::NullableResult;
97 auto *nullabilityAttr =
98 SwiftNullabilityAttr::CreateImplicit(S.
Context, attrNullabilityKind);
99 auto *versioned = SwiftVersionedAdditionAttr::CreateImplicit(
100 S.
Context, metadata.Version, nullabilityAttr, metadata.IsReplacement);
101 decl->addAttr(versioned);
104 if (!metadata.IsActive)
113 void *mem = Ctx.
Allocate(String.size(),
alignof(
char *));
114 memcpy(mem, String.data(), String.size());
115 return StringRef(
static_cast<char *
>(mem), String.size());
127template <
typename A>
struct AttrKindFor {};
130 template <> struct AttrKindFor<X##Attr> { \
131 static const attr::Kind value = attr::X; \
133#include "clang/Basic/AttrList.inc"
141void handleAPINotedAttribute(
142 Sema &S,
Decl *D,
bool IsAddition, VersionedInfoMetadata Metadata,
143 llvm::function_ref<A *()> CreateAttr,
145 if (Metadata.IsActive) {
146 auto Existing = GetExistingAttr(D);
150 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
151 S.
Context, Metadata.Version, *Existing,
true);
159 if (
auto Attr = CreateAttr())
166 if (
auto Attr = CreateAttr()) {
167 auto *Versioned = SwiftVersionedAdditionAttr::CreateImplicit(
169 Metadata.IsReplacement);
176 auto *Versioned = SwiftVersionedRemovalAttr::CreateImplicit(
177 S.
Context, Metadata.Version, AttrKindFor<A>::value,
178 Metadata.IsReplacement);
184void handleAPINotedAttribute(
Sema &S,
Decl *D,
bool ShouldAddAttribute,
185 VersionedInfoMetadata Metadata,
186 llvm::function_ref<A *()> CreateAttr) {
187 handleAPINotedAttribute<A>(
188 S, D, ShouldAddAttribute, Metadata, CreateAttr, [](
const Decl *D) {
189 return llvm::find_if(D->
attrs(),
190 [](
const Attr *
Next) { return isa<A>(Next); });
197 bool ShouldAddAttribute,
198 VersionedInfoMetadata Metadata) {
201 handleAPINotedAttribute<A>(
202 S, D, ShouldAddAttribute, Metadata,
205 return llvm::find_if(D->
attrs(), [](
const Attr *
Next) ->
bool {
206 return isa<CFReturnsRetainedAttr>(Next) ||
207 isa<CFReturnsNotRetainedAttr>(Next) ||
208 isa<NSReturnsRetainedAttr>(Next) ||
209 isa<NSReturnsNotRetainedAttr>(Next) ||
210 isa<CFAuditedTransferAttr>(Next);
216 Sema &S,
Decl *D, VersionedInfoMetadata Metadata,
217 std::optional<api_notes::RetainCountConventionKind> Convention) {
220 switch (*Convention) {
224 S, D,
true, Metadata);
227 S, D,
false, Metadata);
232 S, D,
true, Metadata);
236 S, D,
true, Metadata);
240 S, D,
true, Metadata);
244 S, D,
true, Metadata);
251 VersionedInfoMetadata Metadata) {
254 handleAPINotedAttribute<UnavailableAttr>(S, D,
true, Metadata, [&] {
262 handleAPINotedAttribute<AvailabilityAttr>(
263 S, D,
true, Metadata,
265 return new (S.
Context) AvailabilityAttr(
277 return llvm::find_if(D->
attrs(), [](
const Attr *next) ->
bool {
278 if (const auto *AA = dyn_cast<AvailabilityAttr>(next))
279 if (const auto *II = AA->getPlatform())
280 return II->isStr(
"swift");
288 handleAPINotedAttribute<SwiftPrivateAttr>(
289 S, D, *SwiftPrivate, Metadata, [&] {
298 handleAPINotedAttribute<SwiftAttrAttr>(
301 return SwiftAttrAttr::Create(
308 if (const auto *swiftAttr = dyn_cast<SwiftAttrAttr>(attr)) {
309 if (swiftAttr->getAttribute() ==
"safe" ||
310 swiftAttr->getAttribute() ==
"unsafe")
319 if (!Info.SwiftName.empty()) {
320 handleAPINotedAttribute<SwiftNameAttr>(
321 S, D,
true, Metadata, [&]() -> SwiftNameAttr * {
327 nullptr,
nullptr,
nullptr, ParsedAttr::Form::GNU());
342 VersionedInfoMetadata Metadata) {
345 handleAPINotedAttribute<SwiftBridgeAttr>(
346 S, D, !SwiftBridge->empty(), Metadata, [&] {
347 return new (S.Context)
348 SwiftBridgeAttr(S.Context, getPlaceholderAttrInfo(),
349 ASTAllocateString(S.Context, *SwiftBridge));
355 handleAPINotedAttribute<NSErrorDomainAttr>(
356 S, D, !NSErrorDomain->empty(), Metadata, [&] {
357 return new (S.Context)
358 NSErrorDomainAttr(S.Context, getPlaceholderAttrInfo(),
359 &S.Context.Idents.get(*NSErrorDomain));
365 SwiftAttrAttr::Create(S.
Context,
"conforms_to:" + ConformsTo.value()));
379 S.
Diag(Loc, diag::err_incompatible_replacement_type)
380 << ReplacementType << OrigType;
394 if (
auto Var = dyn_cast<VarDecl>(D)) {
403 Var->getType(),
Type)) {
407 }
else if (
auto property = dyn_cast<ObjCPropertyDecl>(D)) {
409 property->getType(),
Type)) {
412 }
else if (
auto field = dyn_cast<FieldDecl>(D)) {
414 field->getType(),
Type)) {
415 field->setType(
Type);
419 llvm_unreachable(
"API notes allowed a type on an unknown declaration");
433 return (QT.getTypePtr() != Original.getTypePtr()) ? std::optional(QT)
437 if (
auto Function = dyn_cast<FunctionDecl>(D)) {
439 GetModified(D,
Function->getReturnType(), Nullability)) {
443 *Modified, proto->getParamTypes(), proto->getExtProtoInfo()));
448 }
else if (
auto Method = dyn_cast<ObjCMethodDecl>(D)) {
449 if (
auto Modified = GetModified(D,
Method->getReturnType(), Nullability)) {
450 Method->setReturnType(*Modified);
457 }
else if (
auto Value = dyn_cast<ValueDecl>(D)) {
458 if (
auto Modified = GetModified(D,
Value->
getType(), Nullability)) {
459 Value->setType(*Modified);
462 if (
auto Parm = dyn_cast<ParmVarDecl>(D)) {
468 }
else if (
auto Property = dyn_cast<ObjCPropertyDecl>(D)) {
469 if (
auto Modified = GetModified(D,
Property->getType(), Nullability)) {
483 VersionedInfoMetadata Metadata) {
499 VersionedInfoMetadata Metadata) {
502 handleAPINotedAttribute<NoEscapeAttr>(S, D, *NoEscape, Metadata, [&] {
507 handleAPINotedAttribute<LifetimeBoundAttr>(
508 S, D, *Lifetimebound, Metadata, [&] {
525 VersionedInfoMetadata metadata) {
534 VersionedInfoMetadata metadata) {
543 VersionedInfoMetadata Metadata) {
549 handleAPINotedAttribute<SwiftImportPropertyAsAccessorsAttr>(
550 S, D, *AsAccessors, Metadata, [&] {
551 return new (S.
Context) SwiftImportPropertyAsAccessorsAttr(
558typedef llvm::PointerUnion<FunctionDecl *, ObjCMethodDecl *> FunctionOrMethod;
564 VersionedInfoMetadata Metadata) {
574 assert((FD || MD) &&
"Expecting Function or ObjCMethod");
583 bool AnyTypeChanged =
false;
584 for (
unsigned I = 0; I != NumParams; ++I) {
586 QualType ParamTypeBefore = Param->getType();
588 if (I < Info.
Params.size())
595 if (ParamTypeBefore.
getAsOpaquePtr() != Param->getType().getAsOpaquePtr())
596 AnyTypeChanged =
true;
606 if (Metadata.IsActive && !Info.
ResultType.empty() &&
616 auto ResultTypeInfo =
623 OverriddenResultType = ResultType;
624 AnyTypeChanged =
true;
631 if (FD && AnyTypeChanged) {
633 if (OverriddenResultType.
isNull())
634 OverriddenResultType = fnProtoType->getReturnType();
638 ParamTypes.push_back(Param->getType());
641 fnProtoType->getExtProtoInfo()));
642 }
else if (!OverriddenResultType.
isNull()) {
645 OverriddenResultType, FnNoProtoType->getExtInfo()));
661 VersionedInfoMetadata Metadata) {
662 if (Info.
This && Info.
This->isLifetimebound() &&
664 auto MethodType = Method->getType();
670 TLB.
pushFullCopy(Method->getTypeSourceInfo()->getTypeLoc());
673 Method->setType(AttributedType);
683 VersionedInfoMetadata Metadata) {
692 VersionedInfoMetadata Metadata) {
701 VersionedInfoMetadata Metadata) {
704 handleAPINotedAttribute<ObjCDesignatedInitializerAttr>(
705 S, D,
true, Metadata, [&] {
707 IFace->setHasDesignatedInitializers();
709 return new (S.
Context) ObjCDesignatedInitializerAttr(
721 VersionedInfoMetadata Metadata) {
723 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"import_" + ImportAs.value()));
726 D->
addAttr(SwiftAttrAttr::Create(S.
Context,
"retain:" + RetainOp.value()));
730 SwiftAttrAttr::Create(S.
Context,
"release:" + ReleaseOp.value()));
733 SwiftAttrAttr::Create(S.
Context,
"destroy:" + DestroyOp.value()));
735 D->
addAttr(SwiftAttrAttr::Create(
736 S.
Context,
"returned_as_" + DefaultOwnership.value() +
"_by_default"));
745 *Escapable ?
"Escapable" :
"~Escapable"));
750 bool ShouldAddAttribute = (*Extensibility != EnumExtensibilityKind::None);
751 handleAPINotedAttribute<EnumExtensibilityAttr>(
752 S, D, ShouldAddAttribute, Metadata, [&] {
753 EnumExtensibilityAttr::Kind
kind;
754 switch (*Extensibility) {
755 case EnumExtensibilityKind::None:
756 llvm_unreachable(
"remove only");
757 case EnumExtensibilityKind::Open:
758 kind = EnumExtensibilityAttr::Open;
760 case EnumExtensibilityKind::Closed:
761 kind = EnumExtensibilityAttr::Closed;
770 handleAPINotedAttribute<FlagEnumAttr>(S, D, *FlagEnum, Metadata, [&] {
783 VersionedInfoMetadata Metadata) {
788 handleAPINotedAttribute<SwiftNewTypeAttr>(
789 S, D, *SwiftWrapper != SwiftWrapperKind::None, Metadata, [&] {
790 SwiftNewTypeAttr::NewtypeKind Kind;
791 switch (*SwiftWrapper) {
792 case SwiftWrapperKind::None:
793 llvm_unreachable(
"Shouldn't build an attribute");
795 case SwiftWrapperKind::Struct:
796 Kind = SwiftNewTypeAttr::NK_Struct;
799 case SwiftWrapperKind::Enum:
800 Kind = SwiftNewTypeAttr::NK_Enum;
805 AttributeCommonInfo::AT_SwiftNewType,
808 return new (S.
Context) SwiftNewTypeAttr(S.
Context, SyntaxInfo, Kind);
820 VersionedInfoMetadata Metadata) {
829 VersionedInfoMetadata Metadata) {
831 handleAPINotedAttribute<SwiftImportAsNonGenericAttr>(
832 S, D, *AsNonGeneric, Metadata, [&] {
839 handleAPINotedAttribute<SwiftObjCMembersAttr>(
840 S, D, *ObjcMembers, Metadata, [&] {
859template <
typename SpecificInfo>
863 if (D->
hasAttr<SwiftNameAttr>())
869 VersionTuple SelectedVersion;
870 SpecificInfo SelectedInfoSlice;
871 std::tie(SelectedVersion, SelectedInfoSlice) = Info[*Info.
getSelected()];
872 if (SelectedVersion.empty())
874 if (SelectedInfoSlice.SwiftName.empty())
878 for (
const auto &VersionAndInfoSlice : Info) {
879 if (!VersionAndInfoSlice.first.empty())
881 if (!VersionAndInfoSlice.second.SwiftName.empty())
886 VersionedInfoMetadata DummyFutureMetadata(
887 SelectedVersion, IsActive_t::Inactive, IsSubstitution_t::Replacement);
888 handleAPINotedAttribute<SwiftNameAttr>(
889 S, D,
false, DummyFutureMetadata, []() -> SwiftNameAttr * {
890 llvm_unreachable(
"should not try to add an attribute here");
897template <
typename SpecificDecl,
typename SpecificInfo>
899 Sema &S, SpecificDecl *D,
907 VersionTuple Version;
908 SpecificInfo InfoSlice;
909 for (
unsigned i = 0, e = Info.
size(); i != e; ++i) {
910 std::tie(Version, InfoSlice) = Info[i];
911 auto Active = (i == Selected) ? IsActive_t::Active : IsActive_t::Inactive;
912 auto Replacement = IsSubstitution_t::Original;
918 Active = IsActive_t::Inactive;
919 Replacement = IsSubstitution_t::Original;
920 }
else if (Active == IsActive_t::Inactive && Version.empty()) {
921 Replacement = IsSubstitution_t::Replacement;
922 Version = Info[Selected].first;
926 VersionedInfoMetadata(Version, Active, Replacement));
930static std::optional<api_notes::Context>
932 if (
auto NamespaceContext = dyn_cast<NamespaceDecl>(DC)) {
933 for (
auto Reader : APINotes.
findAPINotes(NamespaceContext->getLocation())) {
935 std::stack<NamespaceDecl *> NamespaceStack;
937 for (
auto CurrentNamespace = NamespaceContext; CurrentNamespace;
939 dyn_cast<NamespaceDecl>(CurrentNamespace->getParent())) {
940 if (!CurrentNamespace->isInlineNamespace())
941 NamespaceStack.push(CurrentNamespace);
944 std::optional<api_notes::ContextID> NamespaceID;
945 while (!NamespaceStack.empty()) {
946 auto CurrentNamespace = NamespaceStack.top();
947 NamespaceStack.pop();
949 Reader->lookupNamespaceID(CurrentNamespace->getName(), NamespaceID);
961static std::optional<api_notes::Context>
963 assert(DC &&
"tag context must not be null");
966 std::stack<TagDecl *> TagStack;
968 for (
auto CurrentTag = DC; CurrentTag;
969 CurrentTag = dyn_cast<TagDecl>(CurrentTag->getParent()))
970 TagStack.push(CurrentTag);
972 assert(!TagStack.empty());
973 std::optional<api_notes::Context> Ctx =
975 while (!TagStack.empty()) {
976 auto CurrentTag = TagStack.top();
978 auto CtxID = Reader->lookupTagID(CurrentTag->getName(), Ctx);
996 if (DC->isFileContext() || DC->isNamespace() ||
997 DC->getDeclKind() == Decl::LinkageSpec) {
998 std::optional<api_notes::Context> APINotesContext =
1001 if (
auto VD = dyn_cast<VarDecl>(D)) {
1004 Reader->lookupGlobalVariable(VD->getName(), APINotesContext);
1012 if (
auto FD = dyn_cast<FunctionDecl>(D)) {
1013 if (FD->getDeclName().isIdentifier()) {
1016 Reader->lookupGlobalFunction(FD->getName(), APINotesContext);
1025 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(D)) {
1027 auto Info = Reader->lookupObjCClassInfo(
Class->getName());
1035 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(D)) {
1037 auto Info = Reader->lookupObjCProtocolInfo(Protocol->getName());
1045 if (
auto Tag = dyn_cast<TagDecl>(D)) {
1051 if (
auto typedefName = Tag->getTypedefNameForAnonDecl())
1061 std::string MacroName =
1062 LookupName.empty() && Tag->getOuterLocStart().isMacroID()
1064 Tag->getOuterLocStart(),
1065 Tag->getASTContext().getSourceManager(),
LangOpts)
1070 (MacroName ==
"CF_OPTIONS" || MacroName ==
"NS_OPTIONS" ||
1071 MacroName ==
"OBJC_OPTIONS" || MacroName ==
"SWIFT_OPTIONS")) {
1073 clang::QualType T = llvm::cast<clang::EnumDecl>(Tag)->getIntegerType();
1079 if (
auto ParentTag = dyn_cast<TagDecl>(Tag->getDeclContext()))
1081 auto Info = Reader->lookupTag(
LookupName, APINotesContext);
1089 if (
auto Typedef = dyn_cast<TypedefNameDecl>(D)) {
1091 auto Info = Reader->lookupTypedef(
Typedef->getName(), APINotesContext);
1100 if (DC->getRedeclContext()->isFileContext() ||
1101 DC->getRedeclContext()->isExternCContext()) {
1102 if (
auto EnumConstant = dyn_cast<EnumConstantDecl>(D)) {
1104 auto Info = Reader->lookupEnumConstant(EnumConstant->getName());
1112 if (
auto ObjCContainer = dyn_cast<ObjCContainerDecl>(DC)) {
1115 -> std::optional<api_notes::ContextID> {
1116 if (
auto Protocol = dyn_cast<ObjCProtocolDecl>(ObjCContainer)) {
1117 if (
auto Found = Reader->lookupObjCProtocolID(Protocol->getName()))
1120 return std::nullopt;
1123 if (
auto Impl = dyn_cast<ObjCCategoryImplDecl>(ObjCContainer)) {
1124 if (
auto Cat = Impl->getCategoryDecl())
1125 ObjCContainer = Cat->getClassInterface();
1127 return std::nullopt;
1130 if (
auto Category = dyn_cast<ObjCCategoryDecl>(ObjCContainer)) {
1131 if (Category->getClassInterface())
1132 ObjCContainer = Category->getClassInterface();
1134 return std::nullopt;
1137 if (
auto Impl = dyn_cast<ObjCImplDecl>(ObjCContainer)) {
1138 if (Impl->getClassInterface())
1139 ObjCContainer = Impl->getClassInterface();
1141 return std::nullopt;
1144 if (
auto Class = dyn_cast<ObjCInterfaceDecl>(ObjCContainer)) {
1145 if (
auto Found = Reader->lookupObjCClassID(
Class->getName()))
1148 return std::nullopt;
1151 return std::nullopt;
1155 if (
auto Method = dyn_cast<ObjCMethodDecl>(D)) {
1157 if (
auto Context = GetContext(Reader)) {
1164 for (
unsigned i = 0, n = Sel.
getNumArgs(); i != n; ++i)
1172 auto Info = Reader->lookupObjCMethod(*
Context, SelectorRef,
1173 Method->isInstanceMethod());
1180 if (
auto Property = dyn_cast<ObjCPropertyDecl>(D)) {
1182 if (
auto Context = GetContext(Reader)) {
1183 bool isInstanceProperty =
1184 (
Property->getPropertyAttributesAsWritten() &
1187 isInstanceProperty);
1196 if (
auto TagContext = dyn_cast<TagDecl>(DC)) {
1197 if (
auto CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1203 std::string MethodName;
1204 if (CXXMethod->isOverloadedOperator())
1206 std::string(
"operator") +
1209 MethodName = CXXMethod->getName();
1211 auto Info = Reader->lookupCXXMethod(
Context->id, MethodName);
1218 if (
auto Field = dyn_cast<FieldDecl>(D)) {
1219 if (!Field->isUnnamedBitField() && !Field->isAnonymousStructOrUnion()) {
1222 auto Info = Reader->lookupField(
Context->id, Field->getName());
1229 if (
auto Tag = dyn_cast<TagDecl>(D)) {
1232 auto Info = Reader->lookupTag(Tag->getName(),
Context);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
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.
Attr - This represents one attribute.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
ParsedAttr * create(IdentifierInfo *attrName, SourceRange attrRange, AttributeScopeInfo scope, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Type source information for an attributed type.
void setAttr(const Attr *A)
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
ObjCInterfaceDecl * getClassInterface()
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)
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 UnavailableMsg
Message to use when this entity is unavailable.
std::optional< SwiftSafetyKind > getSwiftSafety() const
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< Decl > decl
Matches declarations.
bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ Property
The type of a property.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ 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