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"
58 LLVM_PREFERRED_TYPE(
bool)
62 LLVM_PREFERRED_TYPE(
bool)
67 LLVM_PREFERRED_TYPE(
bool)
68 unsigned SwiftPrivateSpecified : 1;
71 LLVM_PREFERRED_TYPE(
bool)
72 unsigned SwiftPrivate : 1;
83 return SwiftPrivateSpecified ? std::optional<bool>(SwiftPrivate)
88 SwiftPrivateSpecified =
Private.has_value();
89 SwiftPrivate =
Private.value_or(0);
108 if (!SwiftPrivateSpecified)
117 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
125 LHS.SwiftPrivateSpecified == RHS.SwiftPrivateSpecified &&
131 return !(LHS == RHS);
139 std::optional<std::string> SwiftBridge;
142 std::optional<std::string> NSErrorDomain;
152 SwiftBridge = SwiftType;
156 return NSErrorDomain;
164 NSErrorDomain =
Domain ? std::optional<std::string>(std::string(*
Domain))
182 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
187 LHS.SwiftBridge == RHS.SwiftBridge &&
188 LHS.NSErrorDomain == RHS.NSErrorDomain;
192 return !(LHS == RHS);
199 LLVM_PREFERRED_TYPE(
bool)
200 unsigned HasDefaultNullability : 1;
204 unsigned DefaultNullability : 2;
207 LLVM_PREFERRED_TYPE(
bool)
208 unsigned HasDesignatedInits : 1;
210 LLVM_PREFERRED_TYPE(
bool)
211 unsigned SwiftImportAsNonGenericSpecified : 1;
212 LLVM_PREFERRED_TYPE(
bool)
213 unsigned SwiftImportAsNonGeneric : 1;
215 LLVM_PREFERRED_TYPE(
bool)
216 unsigned SwiftObjCMembersSpecified : 1;
217 LLVM_PREFERRED_TYPE(
bool)
218 unsigned SwiftObjCMembers : 1;
222 : HasDefaultNullability(0), DefaultNullability(0), HasDesignatedInits(0),
223 SwiftImportAsNonGenericSpecified(
false), SwiftImportAsNonGeneric(
false),
224 SwiftObjCMembersSpecified(
false), SwiftObjCMembers(
false) {}
232 return HasDefaultNullability
233 ? std::optional<NullabilityKind>(
240 HasDefaultNullability =
true;
241 DefaultNullability =
static_cast<unsigned>(
Kind);
248 return SwiftImportAsNonGenericSpecified
249 ? std::optional<bool>(SwiftImportAsNonGeneric)
253 SwiftImportAsNonGenericSpecified =
Value.has_value();
254 SwiftImportAsNonGeneric =
Value.value_or(
false);
258 return SwiftObjCMembersSpecified ? std::optional<bool>(SwiftObjCMembers)
262 SwiftObjCMembersSpecified =
Value.has_value();
263 SwiftObjCMembers =
Value.value_or(
false);
277 if (!SwiftImportAsNonGenericSpecified)
280 if (!SwiftObjCMembersSpecified)
283 HasDesignatedInits |= RHS.HasDesignatedInits;
288 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
294 LHS.HasDesignatedInits == RHS.HasDesignatedInits &&
300 return !(LHS == RHS);
306 LLVM_PREFERRED_TYPE(
bool)
307 unsigned NullabilityAudited : 1;
312 unsigned Nullable : 2;
321 return NullabilityAudited ? std::optional<NullabilityKind>(
327 NullabilityAudited =
true;
328 Nullable =
static_cast<unsigned>(kind);
339 if (!NullabilityAudited && RHS.NullabilityAudited)
347 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
352 LHS.NullabilityAudited == RHS.NullabilityAudited &&
353 LHS.Nullable == RHS.Nullable && LHS.Type == RHS.Type;
357 return !(LHS == RHS);
362 LLVM_PREFERRED_TYPE(
bool)
363 unsigned SwiftImportAsAccessorsSpecified : 1;
364 LLVM_PREFERRED_TYPE(
bool)
365 unsigned SwiftImportAsAccessors : 1;
369 : SwiftImportAsAccessorsSpecified(
false), SwiftImportAsAccessors(
false) {}
372 return SwiftImportAsAccessorsSpecified
373 ? std::optional<bool>(SwiftImportAsAccessors)
377 SwiftImportAsAccessorsSpecified =
Value.has_value();
378 SwiftImportAsAccessors =
Value.value_or(
false);
398 if (!SwiftImportAsAccessorsSpecified)
404 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
415 return !(LHS == RHS);
421 LLVM_PREFERRED_TYPE(
bool)
422 unsigned NoEscapeSpecified : 1;
425 LLVM_PREFERRED_TYPE(
bool)
426 unsigned NoEscape : 1;
429 LLVM_PREFERRED_TYPE(
bool)
430 unsigned LifetimeboundSpecified : 1;
433 LLVM_PREFERRED_TYPE(
bool)
434 unsigned Lifetimebound : 1;
439 unsigned RawRetainCountConvention : 3;
444 LifetimeboundSpecified(
false), Lifetimebound(
false),
445 RawRetainCountConvention() {}
448 return NoEscapeSpecified ? std::optional<bool>(NoEscape) : std::nullopt;
451 NoEscapeSpecified =
Value.has_value();
452 NoEscape =
Value.value_or(
false);
456 return LifetimeboundSpecified ? std::optional<bool>(Lifetimebound)
460 LifetimeboundSpecified =
Value.has_value();
461 Lifetimebound =
Value.value_or(
false);
465 if (!RawRetainCountConvention)
471 RawRetainCountConvention =
Value ?
static_cast<unsigned>(*Value) + 1 : 0;
478 if (!NoEscapeSpecified && RHS.NoEscapeSpecified) {
479 NoEscapeSpecified =
true;
480 NoEscape = RHS.NoEscape;
483 if (!LifetimeboundSpecified && RHS.LifetimeboundSpecified) {
484 LifetimeboundSpecified =
true;
485 Lifetimebound = RHS.Lifetimebound;
488 if (!RawRetainCountConvention)
489 RawRetainCountConvention = RHS.RawRetainCountConvention;
496 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
501 LHS.NoEscapeSpecified == RHS.NoEscapeSpecified &&
502 LHS.NoEscape == RHS.NoEscape &&
503 LHS.LifetimeboundSpecified == RHS.LifetimeboundSpecified &&
504 LHS.Lifetimebound == RHS.Lifetimebound &&
505 LHS.RawRetainCountConvention == RHS.RawRetainCountConvention;
509 return !(LHS == RHS);
515 static constexpr const uint64_t NullabilityKindMask = 0x3;
516 static constexpr const unsigned NullabilityKindSize = 2;
518 static constexpr const unsigned ReturnInfoIndex = 0;
526 LLVM_PREFERRED_TYPE(
bool)
561 assert(
static_cast<unsigned>(kind) < NullabilityKindMask);
569 ~(NullabilityKindMask << (index * NullabilityKindSize));
572 unsigned kindValue = (
static_cast<unsigned>(kind))
573 << (index * NullabilityKindSize);
588 return getTypeInfo(index + 1);
609 "Checking the type adjustment on non-audited method.");
615 return static_cast<NullabilityKind>(nullability & NullabilityKindMask);
619 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
633 return !(LHS == RHS);
640 LLVM_PREFERRED_TYPE(
bool)
644 LLVM_PREFERRED_TYPE(
bool)
664 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
674 return !(LHS == RHS);
702 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
710 return !(LHS == RHS);
721 LLVM_PREFERRED_TYPE(
bool)
722 unsigned HasFlagEnum : 1;
723 LLVM_PREFERRED_TYPE(
bool)
724 unsigned IsFlagEnum : 1;
726 LLVM_PREFERRED_TYPE(
bool)
727 unsigned SwiftCopyableSpecified : 1;
728 LLVM_PREFERRED_TYPE(
bool)
729 unsigned SwiftCopyable : 1;
731 LLVM_PREFERRED_TYPE(
bool)
732 unsigned SwiftEscapableSpecified : 1;
733 LLVM_PREFERRED_TYPE(
bool)
734 unsigned SwiftEscapable : 1;
747 : HasFlagEnum(0), IsFlagEnum(0), SwiftCopyableSpecified(
false),
748 SwiftCopyable(
false), SwiftEscapableSpecified(
false),
749 SwiftEscapable(
false) {}
757 HasFlagEnum =
Value.has_value();
758 IsFlagEnum =
Value.value_or(
false);
762 return SwiftCopyableSpecified ? std::optional<bool>(SwiftCopyable)
766 SwiftCopyableSpecified =
Value.has_value();
767 SwiftCopyable =
Value.value_or(
false);
771 return SwiftEscapableSpecified ? std::optional<bool>(SwiftEscapable)
776 SwiftEscapableSpecified =
Value.has_value();
777 SwiftEscapable =
Value.value_or(
false);
799 if (!SwiftCopyableSpecified)
802 if (!SwiftEscapableSpecified)
810 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
826 return !(LHS == RHS);
845 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
854 return !(LHS == RHS);
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
Defines various enumerations that describe declaration and type specifiers.
The base class of the type hierarchy.
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 setSwiftPrivate(std::optional< bool > Private)
std::string UnavailableMsg
Message to use when this entity is unavailable.
friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &)
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)
const std::optional< std::string > & getSwiftBridge() const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
void setNSErrorDomain(const std::optional< std::string > &Domain)
friend bool operator==(const CommonTypeInfo &, const CommonTypeInfo &)
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.
std::optional< NullabilityKind > getDefaultNullability() const
Determine the default nullability for properties and methods of this class.
void setSwiftObjCMembers(std::optional< bool > Value)
friend bool operator==(const ContextInfo &, const ContextInfo &)
bool hasDesignatedInits() const
void setSwiftImportAsNonGeneric(std::optional< bool > Value)
void setHasDesignatedInits(bool Value)
ContextInfo & operator|=(const ContextInfo &RHS)
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.
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
NullabilityKind getParamTypeInfo(unsigned index) const
friend bool operator==(const FunctionInfo &, const FunctionInfo &)
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.
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 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.
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
ObjCPropertyInfo & operator|=(const ObjCPropertyInfo &RHS)
friend bool operator==(const ObjCPropertyInfo &, const ObjCPropertyInfo &)
ObjCPropertyInfo & operator|=(const ContextInfo &RHS)
Merge class-wide information into the given property.
Describes a function or method parameter.
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< EnumExtensibilityKind > EnumExtensibility
void setSwiftCopyable(std::optional< bool > Value)
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)
std::optional< bool > isSwiftEscapable() const
void setFlagEnum(std::optional< bool > Value)
friend bool operator==(const TagInfo &, const TagInfo &)
std::optional< std::string > SwiftConformance
The Swift protocol that this type should be automatically conformed to.
Describes API notes data for a typedef.
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const
TypedefInfo & operator|=(const TypedefInfo &RHS)
std::optional< SwiftNewTypeKind > SwiftWrapper
friend bool operator==(const TypedefInfo &, const TypedefInfo &)
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
friend bool operator==(const VariableInfo &, const VariableInfo &)
VariableInfo & operator|=(const VariableInfo &RHS)
std::optional< NullabilityKind > getNullability() const
const std::string & getType() 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...
Diagnostic wrappers for TextAPI types for error reporting.
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