clang: include/clang/APINotes/Types.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CLANG_APINOTES_TYPES_H
10#define LLVM_CLANG_APINOTES_TYPES_H
11
13#include "llvm/ADT/ArrayRef.h"
14#include "llvm/ADT/StringRef.h"
15#include
16#include
17#include
18
19namespace llvm {
20class raw_ostream;
21}
22
24namespace api_notes {
31};
32
33
34
35
40};
41
42
47};
48
49
50
51
53public:
54
56
57
58 LLVM_PREFERRED_TYPE(bool)
60
61
62 LLVM_PREFERRED_TYPE(bool)
64
65private:
66
67 LLVM_PREFERRED_TYPE(bool)
68 unsigned SwiftPrivateSpecified : 1;
69
70
71 LLVM_PREFERRED_TYPE(bool)
72 unsigned SwiftPrivate : 1;
73
74public:
75
77
80 SwiftPrivate(0) {}
81
83 return SwiftPrivateSpecified ? std::optional(SwiftPrivate)
84 : std::nullopt;
85 }
86
88 SwiftPrivateSpecified = Private.has_value();
89 SwiftPrivate = Private.value_or(0);
90 }
91
93
95
100 }
101
106 }
107
108 if (!SwiftPrivateSpecified)
110
113
114 return *this;
115 }
116
117 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const;
118};
119
125 LHS.SwiftPrivateSpecified == RHS.SwiftPrivateSpecified &&
126 LHS.SwiftPrivate == RHS.SwiftPrivate && LHS.SwiftName == RHS.SwiftName;
127}
128
131 return !(LHS == RHS);
132}
133
134
136
137
138
139 std::optionalstd::string SwiftBridge;
140
141
142 std::optionalstd::string NSErrorDomain;
143
144public:
146
148 return SwiftBridge;
149 }
150
152 SwiftBridge = SwiftType;
153 }
154
156 return NSErrorDomain;
157 }
158
160 NSErrorDomain = Domain;
161 }
162
164 NSErrorDomain = Domain ? std::optionalstd::string(std::string(*Domain))
165 : std::nullopt;
166 }
167
169
171
173
174 if (!SwiftBridge)
176 if (!NSErrorDomain)
178
179 return *this;
180 }
181
182 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const;
183};
184
187 LHS.SwiftBridge == RHS.SwiftBridge &&
188 LHS.NSErrorDomain == RHS.NSErrorDomain;
189}
190
192 return !(LHS == RHS);
193}
194
195
196
198
199 LLVM_PREFERRED_TYPE(bool)
200 unsigned HasDefaultNullability : 1;
201
202
204 unsigned DefaultNullability : 2;
205
206
207 LLVM_PREFERRED_TYPE(bool)
208 unsigned HasDesignatedInits : 1;
209
210 LLVM_PREFERRED_TYPE(bool)
211 unsigned SwiftImportAsNonGenericSpecified : 1;
212 LLVM_PREFERRED_TYPE(bool)
213 unsigned SwiftImportAsNonGeneric : 1;
214
215 LLVM_PREFERRED_TYPE(bool)
216 unsigned SwiftObjCMembersSpecified : 1;
217 LLVM_PREFERRED_TYPE(bool)
218 unsigned SwiftObjCMembers : 1;
219
220public:
222 : HasDefaultNullability(0), DefaultNullability(0), HasDesignatedInits(0),
223 SwiftImportAsNonGenericSpecified(false), SwiftImportAsNonGeneric(false),
224 SwiftObjCMembersSpecified(false), SwiftObjCMembers(false) {}
225
226
227
228
229
230
232 return HasDefaultNullability
233 ? std::optional(
235 : std::nullopt;
236 }
237
238
240 HasDefaultNullability = true;
241 DefaultNullability = static_cast<unsigned>(Kind);
242 }
243
246
248 return SwiftImportAsNonGenericSpecified
249 ? std::optional(SwiftImportAsNonGeneric)
250 : std::nullopt;
251 }
253 SwiftImportAsNonGenericSpecified = Value.has_value();
254 SwiftImportAsNonGeneric = Value.value_or(false);
255 }
256
258 return SwiftObjCMembersSpecified ? std::optional(SwiftObjCMembers)
259 : std::nullopt;
260 }
262 SwiftObjCMembersSpecified = Value.has_value();
263 SwiftObjCMembers = Value.value_or(false);
264 }
265
267
269
271
272
276
277 if (!SwiftImportAsNonGenericSpecified)
279
280 if (!SwiftObjCMembersSpecified)
282
283 HasDesignatedInits |= RHS.HasDesignatedInits;
284
285 return *this;
286 }
287
288 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS);
289};
290
292 return static_cast<const CommonTypeInfo &>(LHS) == RHS &&
294 LHS.HasDesignatedInits == RHS.HasDesignatedInits &&
297}
298
300 return !(LHS == RHS);
301}
302
303
305
306 LLVM_PREFERRED_TYPE(bool)
307 unsigned NullabilityAudited : 1;
308
309
310
312 unsigned Nullable : 2;
313
314
315 std::string Type;
316
317public:
319
321 return NullabilityAudited ? std::optional(
323 : std::nullopt;
324 }
325
327 NullabilityAudited = true;
328 Nullable = static_cast<unsigned>(kind);
329 }
330
333
335
338
339 if (!NullabilityAudited && RHS.NullabilityAudited)
341 if (Type.empty())
342 Type = RHS.Type;
343
344 return *this;
345 }
346
347 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const;
348};
349
352 LHS.NullabilityAudited == RHS.NullabilityAudited &&
353 LHS.Nullable == RHS.Nullable && LHS.Type == RHS.Type;
354}
355
357 return !(LHS == RHS);
358}
359
360
362 LLVM_PREFERRED_TYPE(bool)
363 unsigned SwiftImportAsAccessorsSpecified : 1;
364 LLVM_PREFERRED_TYPE(bool)
365 unsigned SwiftImportAsAccessors : 1;
366
367public:
369 : SwiftImportAsAccessorsSpecified(false), SwiftImportAsAccessors(false) {}
370
372 return SwiftImportAsAccessorsSpecified
373 ? std::optional(SwiftImportAsAccessors)
374 : std::nullopt;
375 }
377 SwiftImportAsAccessorsSpecified = Value.has_value();
378 SwiftImportAsAccessors = Value.value_or(false);
379 }
380
382
383
386
387
391
392 return *this;
393 }
394
397
398 if (!SwiftImportAsAccessorsSpecified)
400
401 return *this;
402 }
403
404 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const;
405};
406
409 return static_cast<const VariableInfo &>(LHS) == RHS &&
411}
412
415 return !(LHS == RHS);
416}
417
418
420
421 LLVM_PREFERRED_TYPE(bool)
422 unsigned NoEscapeSpecified : 1;
423
424
425 LLVM_PREFERRED_TYPE(bool)
426 unsigned NoEscape : 1;
427
428
429 LLVM_PREFERRED_TYPE(bool)
430 unsigned LifetimeboundSpecified : 1;
431
432
433 LLVM_PREFERRED_TYPE(bool)
434 unsigned Lifetimebound : 1;
435
436
437
438
439 unsigned RawRetainCountConvention : 3;
440
441public:
443 : NoEscapeSpecified(false), NoEscape(false),
444 LifetimeboundSpecified(false), Lifetimebound(false),
445 RawRetainCountConvention() {}
446
448 return NoEscapeSpecified ? std::optional(NoEscape) : std::nullopt;
449 }
451 NoEscapeSpecified = Value.has_value();
452 NoEscape = Value.value_or(false);
453 }
454
456 return LifetimeboundSpecified ? std::optional(Lifetimebound)
457 : std::nullopt;
458 }
460 LifetimeboundSpecified = Value.has_value();
461 Lifetimebound = Value.value_or(false);
462 }
463
465 if (!RawRetainCountConvention)
466 return std::nullopt;
468 }
469 void
471 RawRetainCountConvention = Value ? static_cast<unsigned>(*Value) + 1 : 0;
473 }
474
477
478 if (!NoEscapeSpecified && RHS.NoEscapeSpecified) {
479 NoEscapeSpecified = true;
480 NoEscape = RHS.NoEscape;
481 }
482
483 if (!LifetimeboundSpecified && RHS.LifetimeboundSpecified) {
484 LifetimeboundSpecified = true;
485 Lifetimebound = RHS.Lifetimebound;
486 }
487
488 if (!RawRetainCountConvention)
489 RawRetainCountConvention = RHS.RawRetainCountConvention;
490
491 return *this;
492 }
493
495
496 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const;
497};
498
500 return static_cast<const VariableInfo &>(LHS) == RHS &&
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;
506}
507
509 return !(LHS == RHS);
510}
511
512
514private:
515 static constexpr const uint64_t NullabilityKindMask = 0x3;
516 static constexpr const unsigned NullabilityKindSize = 2;
517
518 static constexpr const unsigned ReturnInfoIndex = 0;
519
520public:
521
522
523
524
525
526 LLVM_PREFERRED_TYPE(bool)
528
529
531
532
534
535
536
537
538
539
541
542
544
545
547
548
550
554
557 }
558
561 assert(static_cast<unsigned>(kind) < NullabilityKindMask);
562
566
567
569 ~(NullabilityKindMask << (index * NullabilityKindSize));
570
571
572 unsigned kindValue = (static_cast<unsigned>(kind))
573 << (index * NullabilityKindSize);
575 }
576
577
580 }
581
582
585 }
586
588 return getTypeInfo(index + 1);
589 }
590
592
595 return std::nullopt;
597 }
598 void
602 }
603
605
606private:
609 "Checking the type adjustment on non-audited method.");
610
611
614 auto nullability = NullabilityPayload >> (index * NullabilityKindSize);
615 return static_cast<NullabilityKind>(nullability & NullabilityKindMask);
616 }
617
618public:
619 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const;
620};
621
630}
631
633 return !(LHS == RHS);
634}
635
636
638public:
639
640 LLVM_PREFERRED_TYPE(bool)
642
643
644 LLVM_PREFERRED_TYPE(bool)
646
648
650
652
654
659 }
660 }
661 return *this;
662 }
663
664 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS);
665};
666
668 return static_cast<const FunctionInfo &>(LHS) == RHS &&
671}
672
674 return !(LHS == RHS);
675}
676
677
679public:
681};
682
683
685public:
687};
688
689
691public:
693};
694
695
697public:
699
701
702 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS);
703};
704
706 return static_cast<const FunctionInfo &>(LHS) == RHS && LHS.This == RHS.This;
707}
708
710 return !(LHS == RHS);
711}
712
713
715public:
717};
718
719
721 LLVM_PREFERRED_TYPE(bool)
722 unsigned HasFlagEnum : 1;
723 LLVM_PREFERRED_TYPE(bool)
724 unsigned IsFlagEnum : 1;
725
726 LLVM_PREFERRED_TYPE(bool)
727 unsigned SwiftCopyableSpecified : 1;
728 LLVM_PREFERRED_TYPE(bool)
729 unsigned SwiftCopyable : 1;
730
731 LLVM_PREFERRED_TYPE(bool)
732 unsigned SwiftEscapableSpecified : 1;
733 LLVM_PREFERRED_TYPE(bool)
734 unsigned SwiftEscapable : 1;
735
736public:
740
741
743
745
747 : HasFlagEnum(0), IsFlagEnum(0), SwiftCopyableSpecified(false),
748 SwiftCopyable(false), SwiftEscapableSpecified(false),
749 SwiftEscapable(false) {}
750
752 if (HasFlagEnum)
753 return IsFlagEnum;
754 return std::nullopt;
755 }
757 HasFlagEnum = Value.has_value();
758 IsFlagEnum = Value.value_or(false);
759 }
760
762 return SwiftCopyableSpecified ? std::optional(SwiftCopyable)
763 : std::nullopt;
764 }
766 SwiftCopyableSpecified = Value.has_value();
767 SwiftCopyable = Value.value_or(false);
768 }
769
771 return SwiftEscapableSpecified ? std::optional(SwiftEscapable)
772 : std::nullopt;
773 }
774
776 SwiftEscapableSpecified = Value.has_value();
777 SwiftEscapable = Value.value_or(false);
778 }
779
782
789
792
793 if (!HasFlagEnum)
795
798
799 if (!SwiftCopyableSpecified)
801
802 if (!SwiftEscapableSpecified)
804
805 return *this;
806 }
807
809
810 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS);
811};
812
814 return static_cast<const CommonTypeInfo &>(LHS) == RHS &&
823}
824
826 return !(LHS == RHS);
827}
828
829
831public:
833
835
840 return *this;
841 }
842
844
845 LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const;
846};
847
849 return static_cast<const CommonTypeInfo &>(LHS) == RHS &&
851}
852
854 return !(LHS == RHS);
855}
856
857
859
860
861
863public:
865
867};
868
874};
875
879
881};
882
883
884
885
886
887
888
892};
893}
894}
895
896#endif
enum clang::sema::@1725::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