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;
431 unsigned RawRetainCountConvention : 3;
435 : NoEscapeSpecified(
false), NoEscape(
false), RawRetainCountConvention() {}
438 if (!NoEscapeSpecified)
443 NoEscapeSpecified =
Value.has_value();
444 NoEscape =
Value.value_or(
false);
448 if (!RawRetainCountConvention)
454 RawRetainCountConvention =
Value ?
static_cast<unsigned>(*Value) + 1 : 0;
461 if (!NoEscapeSpecified && RHS.NoEscapeSpecified) {
462 NoEscapeSpecified =
true;
463 NoEscape = RHS.NoEscape;
466 if (!RawRetainCountConvention)
467 RawRetainCountConvention = RHS.RawRetainCountConvention;
474 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
479 LHS.NoEscapeSpecified == RHS.NoEscapeSpecified &&
480 LHS.NoEscape == RHS.NoEscape &&
481 LHS.RawRetainCountConvention == RHS.RawRetainCountConvention;
485 return !(LHS == RHS);
491 static constexpr const uint64_t NullabilityKindMask = 0x3;
492 static constexpr const unsigned NullabilityKindSize = 2;
494 static constexpr const unsigned ReturnInfoIndex = 0;
502 LLVM_PREFERRED_TYPE(
bool)
534 assert(
static_cast<unsigned>(kind) < NullabilityKindMask);
542 ~(NullabilityKindMask << (index * NullabilityKindSize));
545 unsigned kindValue = (
static_cast<unsigned>(kind))
546 << (index * NullabilityKindSize);
561 return getTypeInfo(index + 1);
582 "Checking the type adjustment on non-audited method.");
588 return static_cast<NullabilityKind>(nullability & NullabilityKindMask);
592 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
605 return !(LHS == RHS);
612 LLVM_PREFERRED_TYPE(
bool)
616 LLVM_PREFERRED_TYPE(
bool)
634 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
644 return !(LHS == RHS);
679 LLVM_PREFERRED_TYPE(
bool)
680 unsigned HasFlagEnum : 1;
681 LLVM_PREFERRED_TYPE(
bool)
682 unsigned IsFlagEnum : 1;
684 LLVM_PREFERRED_TYPE(
bool)
685 unsigned SwiftCopyableSpecified : 1;
686 LLVM_PREFERRED_TYPE(
bool)
687 unsigned SwiftCopyable : 1;
700 : HasFlagEnum(0), IsFlagEnum(0), SwiftCopyableSpecified(
false),
701 SwiftCopyable(
false) {}
709 HasFlagEnum =
Value.has_value();
710 IsFlagEnum =
Value.value_or(
false);
714 return SwiftCopyableSpecified ? std::optional<bool>(SwiftCopyable)
718 SwiftCopyableSpecified =
Value.has_value();
719 SwiftCopyable =
Value.value_or(
false);
741 if (!SwiftCopyableSpecified)
749 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS);
764 return !(LHS == RHS);
783 LLVM_DUMP_METHOD
void dump(llvm::raw_ostream &OS)
const;
792 return !(LHS == RHS);
enum clang::sema::@1655::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.
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.
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 &)
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
friend bool operator==(const ParamInfo &, const ParamInfo &)
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)
std::optional< bool > isFlagEnum() const
TagInfo & operator|=(const TagInfo &RHS)
std::optional< bool > isSwiftCopyable() const
LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS)
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.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
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.
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