9#ifndef LLVM_CLANG_APINOTES_TYPES_H
10#define LLVM_CLANG_APINOTES_TYPES_H
13#include "llvm/ADT/ArrayRef.h"
14#include "llvm/ADT/StringRef.h"
60 LLVM_PREFERRED_TYPE(
bool)
64 LLVM_PREFERRED_TYPE(
bool)
69 LLVM_PREFERRED_TYPE(
bool)
70 unsigned SwiftPrivateSpecified : 1;
73 LLVM_PREFERRED_TYPE(
bool)
74 unsigned SwiftPrivate : 1;
76 LLVM_PREFERRED_TYPE(
bool)
77 unsigned SwiftSafetyAudited : 1;
80 unsigned SwiftSafety : 2;
88 SwiftPrivate(0), SwiftSafetyAudited(0), SwiftSafety(0) {}
91 return SwiftPrivateSpecified ? std::optional<bool>(SwiftPrivate)
96 SwiftPrivateSpecified =
Private.has_value();
97 SwiftPrivate =
Private.value_or(0);
101 return SwiftSafetyAudited ? std::optional<SwiftSafetyKind>(
107 SwiftSafetyAudited = 1;
108 SwiftSafety =
static_cast<unsigned>(Safety);
127 if (!SwiftPrivateSpecified)
130 if (!SwiftSafetyAudited && RHS.SwiftSafetyAudited)
139 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
147 LHS.SwiftPrivateSpecified == RHS.SwiftPrivateSpecified &&
148 LHS.SwiftPrivate == RHS.SwiftPrivate &&
149 LHS.SwiftSafetyAudited == RHS.SwiftSafetyAudited &&
155 return !(LHS == RHS);
163 std::optional<std::string> SwiftBridge;
166 std::optional<std::string> NSErrorDomain;
169 std::optional<std::string> SwiftConformance;
179 SwiftBridge = SwiftType;
183 return NSErrorDomain;
191 NSErrorDomain =
Domain ? std::optional<std::string>(std::string(*
Domain))
196 return SwiftConformance;
200 SwiftConformance = conformance;
213 if (SwiftConformance)
219 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
224 LHS.SwiftBridge == RHS.SwiftBridge &&
225 LHS.NSErrorDomain == RHS.NSErrorDomain &&
226 LHS.SwiftConformance == RHS.SwiftConformance;
230 return !(LHS == RHS);
238 unsigned DefaultNullabilityOrNone : 3;
241 LLVM_PREFERRED_TYPE(
bool)
242 unsigned HasDesignatedInits : 1;
244 LLVM_PREFERRED_TYPE(
bool)
245 unsigned SwiftImportAsNonGenericSpecified : 1;
246 LLVM_PREFERRED_TYPE(
bool)
247 unsigned SwiftImportAsNonGeneric : 1;
249 LLVM_PREFERRED_TYPE(
bool)
250 unsigned SwiftObjCMembersSpecified : 1;
251 LLVM_PREFERRED_TYPE(
bool)
252 unsigned SwiftObjCMembers : 1;
256 : DefaultNullabilityOrNone(0), HasDesignatedInits(0),
257 SwiftImportAsNonGenericSpecified(
false), SwiftImportAsNonGeneric(
false),
258 SwiftObjCMembersSpecified(
false), SwiftObjCMembers(
false) {}
267 DefaultNullabilityOrNone);
272 DefaultNullabilityOrNone =
280 return SwiftImportAsNonGenericSpecified
281 ? std::optional<bool>(SwiftImportAsNonGeneric)
285 SwiftImportAsNonGenericSpecified =
Value.has_value();
286 SwiftImportAsNonGeneric =
Value.value_or(
false);
290 return SwiftObjCMembersSpecified ? std::optional<bool>(SwiftObjCMembers)
294 SwiftObjCMembersSpecified =
Value.has_value();
295 SwiftObjCMembers =
Value.value_or(
false);
309 if (!SwiftImportAsNonGenericSpecified)
312 if (!SwiftObjCMembersSpecified)
315 HasDesignatedInits |= RHS.HasDesignatedInits;
320 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
326 LHS.HasDesignatedInits == RHS.HasDesignatedInits &&
332 return !(LHS == RHS);
352 LLVM_PREFERRED_TYPE(
bool)
353 unsigned KindAudited : 1;
360 LLVM_PREFERRED_TYPE(
bool)
361 unsigned LevelAudited : 1;
367 : Kind(0), KindAudited(
false), Level(0), LevelAudited(
false),
370 std::optional<BoundsSafetyKind>
getKind()
const {
371 return KindAudited ? std::optional<BoundsSafetyKind>(
378 Kind =
static_cast<unsigned>(
kind);
382 return LevelAudited ? std::optional<unsigned>(Level) : std::nullopt;
392 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
397 return LHS.KindAudited == RHS.KindAudited && LHS.Kind == RHS.Kind &&
398 LHS.LevelAudited == RHS.LevelAudited && LHS.Level == RHS.Level &&
404 return !(LHS == RHS);
412 unsigned NullabilityOrNone : 3;
428 const std::string &
getType()
const {
return Type; }
444 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
449 LHS.NullabilityOrNone == RHS.NullabilityOrNone && LHS.Type == RHS.Type;
453 return !(LHS == RHS);
458 LLVM_PREFERRED_TYPE(
bool)
459 unsigned SwiftImportAsAccessorsSpecified : 1;
460 LLVM_PREFERRED_TYPE(
bool)
461 unsigned SwiftImportAsAccessors : 1;
465 : SwiftImportAsAccessorsSpecified(
false), SwiftImportAsAccessors(
false) {}
468 return SwiftImportAsAccessorsSpecified
469 ? std::optional<bool>(SwiftImportAsAccessors)
473 SwiftImportAsAccessorsSpecified =
Value.has_value();
474 SwiftImportAsAccessors =
Value.value_or(
false);
494 if (!SwiftImportAsAccessorsSpecified)
500 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
511 return !(LHS == RHS);
517 LLVM_PREFERRED_TYPE(
bool)
518 unsigned NoEscapeSpecified : 1;
521 LLVM_PREFERRED_TYPE(
bool)
522 unsigned NoEscape : 1;
525 LLVM_PREFERRED_TYPE(
bool)
526 unsigned LifetimeboundSpecified : 1;
529 LLVM_PREFERRED_TYPE(
bool)
530 unsigned Lifetimebound : 1;
535 unsigned RawRetainCountConvention : 3;
542 LifetimeboundSpecified(
false), Lifetimebound(
false),
546 return NoEscapeSpecified ? std::optional<bool>(NoEscape) : std::nullopt;
549 NoEscapeSpecified =
Value.has_value();
550 NoEscape =
Value.value_or(
false);
554 return LifetimeboundSpecified ? std::optional<bool>(Lifetimebound)
558 LifetimeboundSpecified =
Value.has_value();
559 Lifetimebound =
Value.value_or(
false);
563 if (!RawRetainCountConvention)
569 RawRetainCountConvention =
Value ?
static_cast<unsigned>(*Value) + 1 : 0;
576 if (!NoEscapeSpecified && RHS.NoEscapeSpecified) {
577 NoEscapeSpecified =
true;
578 NoEscape = RHS.NoEscape;
581 if (!LifetimeboundSpecified && RHS.LifetimeboundSpecified) {
582 LifetimeboundSpecified =
true;
583 Lifetimebound = RHS.Lifetimebound;
586 if (!RawRetainCountConvention)
587 RawRetainCountConvention = RHS.RawRetainCountConvention;
597 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
602 LHS.NoEscapeSpecified == RHS.NoEscapeSpecified &&
603 LHS.NoEscape == RHS.NoEscape &&
604 LHS.LifetimeboundSpecified == RHS.LifetimeboundSpecified &&
605 LHS.Lifetimebound == RHS.Lifetimebound &&
606 LHS.RawRetainCountConvention == RHS.RawRetainCountConvention &&
611 return !(LHS == RHS);
617 static constexpr const uint64_t NullabilityKindMask = 0x3;
618 static constexpr const unsigned NullabilityKindSize = 2;
620 static constexpr const unsigned ReturnInfoIndex = 0;
628 LLVM_PREFERRED_TYPE(
bool)
638 LLVM_PREFERRED_TYPE(
bool)
667 assert(
static_cast<unsigned>(
kind) < NullabilityKindMask);
675 ~(NullabilityKindMask << (
index * NullabilityKindSize));
678 unsigned kindValue = (
static_cast<unsigned>(
kind))
679 << (
index * NullabilityKindSize);
694 return getTypeInfo(
index + 1);
715 "Checking the type adjustment on non-audited method.");
721 return static_cast<NullabilityKind>(nullability & NullabilityKindMask);
725 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
740 return !(LHS == RHS);
747 LLVM_PREFERRED_TYPE(
bool)
751 LLVM_PREFERRED_TYPE(
bool)
771 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
781 return !(LHS == RHS);
809 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
817 return !(LHS == RHS);
828 LLVM_PREFERRED_TYPE(
bool)
829 unsigned HasFlagEnum : 1;
830 LLVM_PREFERRED_TYPE(
bool)
831 unsigned IsFlagEnum : 1;
833 LLVM_PREFERRED_TYPE(
bool)
834 unsigned SwiftCopyableSpecified : 1;
835 LLVM_PREFERRED_TYPE(
bool)
836 unsigned SwiftCopyable : 1;
838 LLVM_PREFERRED_TYPE(
bool)
839 unsigned SwiftEscapableSpecified : 1;
840 LLVM_PREFERRED_TYPE(
bool)
841 unsigned SwiftEscapable : 1;
853 : HasFlagEnum(0), IsFlagEnum(0), SwiftCopyableSpecified(
false),
854 SwiftCopyable(
false), SwiftEscapableSpecified(
false),
855 SwiftEscapable(
false) {}
863 HasFlagEnum =
Value.has_value();
864 IsFlagEnum =
Value.value_or(
false);
868 return SwiftCopyableSpecified ? std::optional<bool>(SwiftCopyable)
872 SwiftCopyableSpecified =
Value.has_value();
873 SwiftCopyable =
Value.value_or(
false);
877 return SwiftEscapableSpecified ? std::optional<bool>(SwiftEscapable)
882 SwiftEscapableSpecified =
Value.has_value();
883 SwiftEscapable =
Value.value_or(
false);
906 if (!SwiftCopyableSpecified)
909 if (!SwiftEscapableSpecified)
917 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
934 return !(LHS == RHS);
953 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
962 return !(LHS == RHS);
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Defines various enumerations that describe declaration and type specifiers.
std::optional< BoundsSafetyKind > getKind() const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< unsigned > getLevel() const
friend bool operator==(const BoundsSafetyInfo &, const BoundsSafetyInfo &)
std::string ExternalBounds
void setKindAudited(BoundsSafetyKind kind)
void setLevelAudited(unsigned level)
Describes API notes data for a C++ method.
std::optional< ParamInfo > This
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
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.
void setSwiftSafety(SwiftSafetyKind Safety)
void setSwiftPrivate(std::optional< bool > Private)
friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &)
std::string UnavailableMsg
Message to use when this entity is unavailable.
std::optional< SwiftSafetyKind > getSwiftSafety() const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< bool > isSwiftPrivate() const
CommonEntityInfo & operator|=(const CommonEntityInfo &RHS)
Describes API notes for types.
void setNSErrorDomain(const std::optional< llvm::StringRef > &Domain)
friend bool operator==(const CommonTypeInfo &, const CommonTypeInfo &)
std::optional< std::string > getSwiftConformance() const
const std::optional< std::string > & getSwiftBridge() const
void setSwiftConformance(std::optional< std::string > conformance)
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
void setNSErrorDomain(const std::optional< std::string > &Domain)
const std::optional< std::string > & getNSErrorDomain() const
void setSwiftBridge(std::optional< std::string > SwiftType)
CommonTypeInfo & operator|=(const CommonTypeInfo &RHS)
Opaque context ID used to refer to an Objective-C class or protocol or a C++ namespace.
ContextID(unsigned value)
Describes API notes data for an Objective-C class or protocol or a C++ namespace.
std::optional< bool > getSwiftImportAsNonGeneric() const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
std::optional< bool > getSwiftObjCMembers() const
void setDefaultNullability(NullabilityKind Kind)
Set the default nullability for properties and methods of this class.
NullabilityKindOrNone getDefaultNullability() const
Determine the default nullability for properties and methods of this class.
void setSwiftObjCMembers(std::optional< bool > Value)
bool hasDesignatedInits() const
void setSwiftImportAsNonGeneric(std::optional< bool > Value)
void setHasDesignatedInits(bool Value)
friend bool operator==(const ContextInfo &, const ContextInfo &)
ContextInfo & operator|=(const ContextInfo &RHS)
API notes for a function or method.
std::string SwiftReturnOwnership
Ownership convention for return value.
void addTypeInfo(unsigned index, NullabilityKind kind)
uint64_t NullabilityPayload
Stores the nullability of the return type and the parameters.
std::optional< RetainCountConventionKind > getRetainCountConvention() const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
void setRetainCountConvention(std::optional< RetainCountConventionKind > Value)
unsigned RawRetainCountConvention
A biased RetainCountConventionKind, where 0 means "unspecified".
std::vector< ParamInfo > Params
The function parameters.
NullabilityKind getReturnTypeInfo() const
friend bool operator==(const FunctionInfo &, const FunctionInfo &)
NullabilityKind getParamTypeInfo(unsigned index) const
unsigned NumAdjustedNullable
Number of types whose nullability is encoded with the NullabilityPayload.
std::string ResultType
The result type of this function, as a C type.
unsigned UnsafeBufferUsage
Whether the function has the [[clang::unsafe_buffer_usage]] attribute.
static unsigned getMaxNullabilityIndex()
void addReturnTypeInfo(NullabilityKind kind)
Adds the return type info.
unsigned NullabilityAudited
Whether the signature has been audited with respect to nullability.
void addParamTypeInfo(unsigned index, NullabilityKind kind)
Adds the parameter type info.
Describes API notes data for an Objective-C method.
unsigned DesignatedInit
Whether this is a designated initializer of its class.
friend bool operator==(const ObjCMethodInfo &, const ObjCMethodInfo &)
std::optional< ParamInfo > Self
ObjCMethodInfo & operator|=(const ContextInfo &RHS)
unsigned RequiredInit
Whether this is a required initializer.
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
Describes API notes data for an Objective-C property.
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
void setSwiftImportAsAccessors(std::optional< bool > Value)
std::optional< bool > getSwiftImportAsAccessors() const
friend bool operator==(const ObjCPropertyInfo &, const ObjCPropertyInfo &)
ObjCPropertyInfo & operator|=(const ObjCPropertyInfo &RHS)
ObjCPropertyInfo & operator|=(const ContextInfo &RHS)
Merge class-wide information into the given property.
Describes a function or method parameter.
std::optional< BoundsSafetyInfo > BoundsSafety
void setNoEscape(std::optional< bool > Value)
std::optional< bool > isNoEscape() const
ParamInfo & operator|=(const ParamInfo &RHS)
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
std::optional< bool > isLifetimebound() const
friend bool operator==(const ParamInfo &, const ParamInfo &)
void setLifetimebound(std::optional< bool > Value)
std::optional< RetainCountConventionKind > getRetainCountConvention() const
void setRetainCountConvention(std::optional< RetainCountConventionKind > Value)
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
void setSwiftCopyable(std::optional< bool > Value)
std::optional< std::string > SwiftDestroyOp
void setSwiftEscapable(std::optional< bool > Value)
std::optional< bool > isFlagEnum() const
TagInfo & operator|=(const TagInfo &RHS)
std::optional< bool > isSwiftCopyable() const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
friend bool operator==(const TagInfo &, const TagInfo &)
std::optional< bool > isSwiftEscapable() const
void setFlagEnum(std::optional< bool > Value)
Describes API notes data for a typedef.
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
TypedefInfo & operator|=(const TypedefInfo &RHS)
friend bool operator==(const TypedefInfo &, const TypedefInfo &)
std::optional< SwiftNewTypeKind > SwiftWrapper
API notes for a variable/property.
void setNullabilityAudited(NullabilityKind kind)
void setType(const std::string &type)
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
VariableInfo & operator|=(const VariableInfo &RHS)
const std::string & getType() const
friend bool operator==(const VariableInfo &, const VariableInfo &)
NullabilityKindOrNone getNullability() const
bool operator!=(const CommonEntityInfo &LHS, const CommonEntityInfo &RHS)
bool operator==(const CommonEntityInfo &LHS, const CommonEntityInfo &RHS)
RetainCountConventionKind
SwiftNewTypeKind
The kind of a swift_wrapper/swift_newtype.
EnumExtensibilityKind
The payload for an enum_extensibility attribute.
static const constexpr char SOURCE_APINOTES_EXTENSION[]
The file extension used for the source representation of API notes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ NonNull
Values of this type can never be null.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
OptionalUnsigned< NullabilityKind > NullabilityKindOrNone
Diagnostic wrappers for TextAPI types for error reporting.
constexpr underlying_type toInternalRepresentation() const
static constexpr OptionalUnsigned fromInternalRepresentation(underlying_type Rep)
Context(ContextID id, ContextKind kind)
A temporary reference to an Objective-C selector, suitable for referencing selector data on the stack...
llvm::ArrayRef< llvm::StringRef > Identifiers