17#include "llvm/ADT/Hashing.h"
18#include "llvm/ADT/StringExtras.h"
19#include "llvm/Bitstream/BitstreamReader.h"
20#include "llvm/Support/DJB.h"
21#include "llvm/Support/EndianStream.h"
22#include "llvm/Support/OnDiskHashTable.h"
26using namespace llvm::support;
30llvm::VersionTuple ReadVersionTuple(
const uint8_t *&
Data) {
31 uint8_t NumVersions = (*
Data++) & 0x03;
33 unsigned Major = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
35 return llvm::VersionTuple(Major);
37 unsigned Minor = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
39 return llvm::VersionTuple(Major, Minor);
42 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
44 return llvm::VersionTuple(Major, Minor, Subminor);
46 unsigned Build = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
47 return llvm::VersionTuple(Major, Minor, Subminor, Build);
51template <
typename Derived,
typename KeyType,
typename UnversionedDataType>
52class VersionedTableInfo {
54 using internal_key_type = KeyType;
55 using external_key_type = KeyType;
58 using hash_value_type =
size_t;
61 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
63 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
65 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
69 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
71 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
73 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
74 return {KeyLength, DataLength};
77 static data_type ReadData(internal_key_type Key,
const uint8_t *
Data,
79 unsigned NumElements =
80 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
82 Result.reserve(NumElements);
83 for (
unsigned i = 0; i != NumElements; ++i) {
84 auto version = ReadVersionTuple(
Data);
85 const auto *DataBefore =
Data;
87 auto UnversionedData = Derived::readUnversioned(Key,
Data);
88 assert(
Data != DataBefore &&
89 "Unversioned data reader didn't move pointer");
90 Result.push_back({version, UnversionedData});
97void ReadCommonEntityInfo(
const uint8_t *&
Data, CommonEntityInfo &Info) {
98 uint8_t UnavailableBits = *
Data++;
99 Info.Unavailable = (UnavailableBits >> 1) & 0x01;
100 Info.UnavailableInSwift = UnavailableBits & 0x01;
101 if ((UnavailableBits >> 2) & 0x01)
102 Info.setSwiftPrivate(
static_cast<bool>((UnavailableBits >> 3) & 0x01));
105 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
106 Info.UnavailableMsg =
107 std::string(
reinterpret_cast<const char *
>(
Data),
108 reinterpret_cast<const char *
>(
Data) + MsgLength);
111 unsigned SwiftNameLength =
112 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
114 std::string(
reinterpret_cast<const char *
>(
Data),
115 reinterpret_cast<const char *
>(
Data) + SwiftNameLength);
116 Data += SwiftNameLength;
120void ReadCommonTypeInfo(
const uint8_t *&
Data, CommonTypeInfo &Info) {
121 ReadCommonEntityInfo(
Data, Info);
123 unsigned SwiftBridgeLength =
124 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
125 if (SwiftBridgeLength > 0) {
126 Info.setSwiftBridge(std::string(
reinterpret_cast<const char *
>(
Data),
127 SwiftBridgeLength - 1));
128 Data += SwiftBridgeLength - 1;
131 unsigned ErrorDomainLength =
132 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
133 if (ErrorDomainLength > 0) {
134 Info.setNSErrorDomain(std::optional<std::string>(std::string(
135 reinterpret_cast<const char *
>(
Data), ErrorDomainLength - 1)));
136 Data += ErrorDomainLength - 1;
141class IdentifierTableInfo {
143 using internal_key_type = llvm::StringRef;
144 using external_key_type = llvm::StringRef;
149 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
151 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
153 hash_value_type
ComputeHash(internal_key_type Key) {
154 return llvm::djbHash(Key);
157 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
161 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
163 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
164 unsigned DataLength =
165 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
166 return {KeyLength, DataLength};
169 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
170 return llvm::StringRef(
reinterpret_cast<const char *
>(
Data), Length);
173 static data_type ReadData(internal_key_type key,
const uint8_t *
Data,
175 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
181class ContextIDTableInfo {
183 using internal_key_type = ContextTableKey;
184 using external_key_type = internal_key_type;
186 using hash_value_type =
size_t;
189 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
191 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
193 hash_value_type
ComputeHash(internal_key_type Key) {
194 return static_cast<size_t>(Key.hashValue());
197 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
201 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
203 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
204 unsigned DataLength =
205 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
206 return {KeyLength, DataLength};
209 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
211 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
213 endian::readNext<uint8_t, llvm::endianness::little>(
Data);
214 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
218 static data_type ReadData(internal_key_type Key,
const uint8_t *
Data,
220 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
225class ContextInfoTableInfo
226 :
public VersionedTableInfo<ContextInfoTableInfo, unsigned, ContextInfo> {
228 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
229 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
232 hash_value_type
ComputeHash(internal_key_type Key) {
236 static ContextInfo readUnversioned(internal_key_type Key,
237 const uint8_t *&
Data) {
239 ReadCommonTypeInfo(
Data, Info);
240 uint8_t Payload = *
Data++;
243 Info.setHasDesignatedInits(
true);
244 Payload = Payload >> 1;
247 Info.setDefaultNullability(
static_cast<NullabilityKind>(Payload & 0x03));
250 if (Payload & (1 << 1))
251 Info.setSwiftObjCMembers(Payload & 1);
254 if (Payload & (1 << 1))
255 Info.setSwiftImportAsNonGeneric(Payload & 1);
262void ReadVariableInfo(
const uint8_t *&
Data, VariableInfo &Info) {
263 ReadCommonEntityInfo(
Data, Info);
269 auto TypeLen = endian::readNext<uint16_t, llvm::endianness::little>(
Data);
270 Info.setType(std::string(
Data,
Data + TypeLen));
275class ObjCPropertyTableInfo
276 :
public VersionedTableInfo<ObjCPropertyTableInfo,
277 std::tuple<uint32_t, uint32_t, uint8_t>,
280 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
281 auto ClassID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
282 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
283 char IsInstance = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
284 return {ClassID, NameID, IsInstance};
287 hash_value_type
ComputeHash(internal_key_type Key) {
291 static ObjCPropertyInfo readUnversioned(internal_key_type Key,
292 const uint8_t *&
Data) {
293 ObjCPropertyInfo Info;
294 ReadVariableInfo(
Data, Info);
295 uint8_t Flags = *
Data++;
296 if (Flags & (1 << 0))
297 Info.setSwiftImportAsAccessors(Flags & (1 << 1));
304 :
public VersionedTableInfo<FieldTableInfo, SingleDeclTableKey, FieldInfo> {
306 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
307 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
308 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
309 return {CtxID, NameID};
312 hash_value_type
ComputeHash(internal_key_type Key) {
313 return static_cast<size_t>(Key.hashValue());
316 static FieldInfo readUnversioned(internal_key_type Key,
317 const uint8_t *&
Data) {
319 ReadVariableInfo(
Data, Info);
325void ReadParamInfo(
const uint8_t *&
Data, ParamInfo &Info) {
326 ReadVariableInfo(
Data, Info);
328 uint8_t Payload = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
329 if (
auto RawConvention = Payload & 0x7) {
331 Info.setRetainCountConvention(Convention);
335 Info.setNoEscape(Payload & 0x02);
337 assert(Payload == 0 &&
"Bad API notes");
341void ReadFunctionInfo(
const uint8_t *&
Data, FunctionInfo &Info) {
342 ReadCommonEntityInfo(
Data, Info);
344 uint8_t Payload = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
345 if (
auto RawConvention = Payload & 0x7) {
347 Info.setRetainCountConvention(Convention);
350 Info.NullabilityAudited = Payload & 0x1;
352 assert(Payload == 0 &&
"Bad API notes");
354 Info.NumAdjustedNullable =
355 endian::readNext<uint8_t, llvm::endianness::little>(
Data);
356 Info.NullabilityPayload =
357 endian::readNext<uint64_t, llvm::endianness::little>(
Data);
360 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
361 while (NumParams > 0) {
363 ReadParamInfo(
Data, pi);
364 Info.Params.push_back(pi);
368 unsigned ResultTypeLen =
369 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
370 Info.ResultType = std::string(
Data,
Data + ResultTypeLen);
371 Data += ResultTypeLen;
375class ObjCMethodTableInfo
376 :
public VersionedTableInfo<ObjCMethodTableInfo,
377 std::tuple<uint32_t, uint32_t, uint8_t>,
380 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
381 auto ClassID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
383 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
384 auto IsInstance = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
388 hash_value_type
ComputeHash(internal_key_type Key) {
392 static ObjCMethodInfo readUnversioned(internal_key_type Key,
393 const uint8_t *&
Data) {
395 uint8_t Payload = *
Data++;
396 Info.RequiredInit = Payload & 0x01;
398 Info.DesignatedInit = Payload & 0x01;
401 ReadFunctionInfo(
Data, Info);
407class ObjCSelectorTableInfo {
409 using internal_key_type = StoredObjCSelector;
410 using external_key_type = internal_key_type;
415 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
417 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
419 hash_value_type
ComputeHash(internal_key_type Key) {
420 return llvm::DenseMapInfo<StoredObjCSelector>::getHashValue(Key);
423 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
424 return llvm::DenseMapInfo<StoredObjCSelector>::isEqual(LHS, RHS);
427 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
429 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
430 unsigned DataLength =
431 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
432 return {KeyLength, DataLength};
435 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
436 internal_key_type Key;
437 Key.NumArgs = endian::readNext<uint16_t, llvm::endianness::little>(
Data);
438 unsigned NumIdents = (Length -
sizeof(uint16_t)) /
sizeof(
uint32_t);
439 for (
unsigned i = 0; i != NumIdents; ++i) {
440 Key.Identifiers.push_back(
441 endian::readNext<uint32_t, llvm::endianness::little>(
Data));
446 static data_type ReadData(internal_key_type Key,
const uint8_t *
Data,
448 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
453class GlobalVariableTableInfo
454 :
public VersionedTableInfo<GlobalVariableTableInfo, SingleDeclTableKey,
455 GlobalVariableInfo> {
457 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
458 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
459 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
460 return {CtxID, NameID};
463 hash_value_type
ComputeHash(internal_key_type Key) {
464 return static_cast<size_t>(Key.hashValue());
467 static GlobalVariableInfo readUnversioned(internal_key_type Key,
468 const uint8_t *&
Data) {
469 GlobalVariableInfo Info;
470 ReadVariableInfo(
Data, Info);
476class GlobalFunctionTableInfo
477 :
public VersionedTableInfo<GlobalFunctionTableInfo, SingleDeclTableKey,
478 GlobalFunctionInfo> {
480 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
481 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
482 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
483 return {CtxID, NameID};
486 hash_value_type
ComputeHash(internal_key_type Key) {
487 return static_cast<size_t>(Key.hashValue());
490 static GlobalFunctionInfo readUnversioned(internal_key_type Key,
491 const uint8_t *&
Data) {
492 GlobalFunctionInfo Info;
493 ReadFunctionInfo(
Data, Info);
499class CXXMethodTableInfo
500 :
public VersionedTableInfo<CXXMethodTableInfo, SingleDeclTableKey,
503 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
504 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
505 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
506 return {CtxID, NameID};
509 hash_value_type
ComputeHash(internal_key_type Key) {
510 return static_cast<size_t>(Key.hashValue());
513 static CXXMethodInfo readUnversioned(internal_key_type Key,
514 const uint8_t *&
Data) {
516 ReadFunctionInfo(
Data, Info);
522class EnumConstantTableInfo
523 :
public VersionedTableInfo<EnumConstantTableInfo, uint32_t,
526 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
527 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
531 hash_value_type
ComputeHash(internal_key_type Key) {
535 static EnumConstantInfo readUnversioned(internal_key_type Key,
536 const uint8_t *&
Data) {
537 EnumConstantInfo Info;
538 ReadCommonEntityInfo(
Data, Info);
545 :
public VersionedTableInfo<TagTableInfo, SingleDeclTableKey, TagInfo> {
547 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
548 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
550 endian::readNext<IdentifierID, llvm::endianness::little>(
Data);
551 return {CtxID, NameID};
554 hash_value_type
ComputeHash(internal_key_type Key) {
555 return static_cast<size_t>(Key.hashValue());
558 static TagInfo readUnversioned(internal_key_type Key,
const uint8_t *&
Data) {
561 uint8_t Payload = *
Data++;
563 Info.setFlagEnum(Payload & 2);
566 Info.EnumExtensibility =
570 endian::readNext<uint8_t, llvm::endianness::little>(
Data);
572 Info.setSwiftCopyable(std::optional(
false));
574 Info.setSwiftCopyable(std::optional(
true));
576 unsigned ImportAsLength =
577 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
578 if (ImportAsLength > 0) {
580 std::string(
reinterpret_cast<const char *
>(
Data), ImportAsLength - 1);
581 Data += ImportAsLength - 1;
583 unsigned RetainOpLength =
584 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
585 if (RetainOpLength > 0) {
587 std::string(
reinterpret_cast<const char *
>(
Data), RetainOpLength - 1);
588 Data += RetainOpLength - 1;
590 unsigned ReleaseOpLength =
591 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
592 if (ReleaseOpLength > 0) {
593 Info.SwiftReleaseOp = std::string(
reinterpret_cast<const char *
>(
Data),
594 ReleaseOpLength - 1);
595 Data += ReleaseOpLength - 1;
597 if (
unsigned ConformanceLength =
598 endian::readNext<uint16_t, llvm::endianness::little>(
Data)) {
599 Info.SwiftConformance = std::string(
reinterpret_cast<const char *
>(
Data),
600 ConformanceLength - 1);
601 Data += ConformanceLength - 1;
604 ReadCommonTypeInfo(
Data, Info);
610class TypedefTableInfo
611 :
public VersionedTableInfo<TypedefTableInfo, SingleDeclTableKey,
614 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
615 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
617 endian::readNext<IdentifierID, llvm::endianness::little>(
Data);
618 return {CtxID, nameID};
621 hash_value_type
ComputeHash(internal_key_type Key) {
622 return static_cast<size_t>(Key.hashValue());
625 static TypedefInfo readUnversioned(internal_key_type Key,
626 const uint8_t *&
Data) {
629 uint8_t Payload = *
Data++;
633 ReadCommonTypeInfo(
Data, Info);
655 llvm::OnDiskIterableChainedHashTable<IdentifierTableInfo>;
661 llvm::OnDiskIterableChainedHashTable<ContextIDTableInfo>;
667 llvm::OnDiskIterableChainedHashTable<ContextInfoTableInfo>;
673 llvm::OnDiskIterableChainedHashTable<ObjCPropertyTableInfo>;
679 llvm::OnDiskIterableChainedHashTable<FieldTableInfo>;
685 llvm::OnDiskIterableChainedHashTable<ObjCMethodTableInfo>;
691 llvm::OnDiskIterableChainedHashTable<CXXMethodTableInfo>;
697 llvm::OnDiskIterableChainedHashTable<ObjCSelectorTableInfo>;
703 llvm::OnDiskIterableChainedHashTable<GlobalVariableTableInfo>;
709 llvm::OnDiskIterableChainedHashTable<GlobalFunctionTableInfo>;
715 llvm::OnDiskIterableChainedHashTable<EnumConstantTableInfo>;
726 llvm::OnDiskIterableChainedHashTable<TypedefTableInfo>;
733 std::optional<IdentifierID>
getIdentifier(llvm::StringRef Str);
767std::optional<IdentifierID>
782std::optional<SelectorID>
790 for (
auto Ident :
Selector.Identifiers) {
798 auto Known = ObjCSelectorTable->find(Key);
799 if (Known == ObjCSelectorTable->end())
810 bool SawMetadata =
false;
815 consumeError(MaybeNext.takeError());
818 llvm::BitstreamEntry Next = MaybeNext.get();
820 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
821 if (Next.Kind == llvm::BitstreamEntry::Error)
824 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
827 if (Cursor.SkipBlock())
830 MaybeNext = Cursor.advance();
833 consumeError(MaybeNext.takeError());
836 Next = MaybeNext.get();
841 llvm::StringRef BlobData;
843 Cursor.readRecord(Next.ID, Scratch, &BlobData);
846 consumeError(MaybeKind.takeError());
849 unsigned Kind = MaybeKind.get();
864 ModuleName = BlobData.str();
871 SourceFileSizeAndModTime = {Scratch[0], Scratch[1]};
880 MaybeNext = Cursor.advance();
883 consumeError(MaybeNext.takeError());
886 Next = MaybeNext.get();
900 consumeError(MaybeNext.takeError());
903 llvm::BitstreamEntry Next = MaybeNext.get();
905 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
906 if (Next.Kind == llvm::BitstreamEntry::Error)
909 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
912 if (Cursor.SkipBlock())
915 MaybeNext = Cursor.advance();
918 consumeError(MaybeNext.takeError());
921 Next = MaybeNext.get();
926 llvm::StringRef BlobData;
928 Cursor.readRecord(Next.ID, Scratch, &BlobData);
931 consumeError(MaybeKind.takeError());
934 unsigned Kind = MaybeKind.get();
941 uint32_t tableOffset;
942 identifier_block::IdentifierDataLayout::readRecord(Scratch, tableOffset);
943 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
946 base + tableOffset, base +
sizeof(uint32_t), base));
956 MaybeNext = Cursor.advance();
959 consumeError(MaybeNext.takeError());
962 Next = MaybeNext.get();
976 consumeError(MaybeNext.takeError());
979 llvm::BitstreamEntry Next = MaybeNext.get();
981 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
982 if (Next.Kind == llvm::BitstreamEntry::Error)
985 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
988 if (Cursor.SkipBlock())
991 MaybeNext = Cursor.advance();
994 consumeError(MaybeNext.takeError());
997 Next = MaybeNext.get();
1002 llvm::StringRef BlobData;
1004 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1007 consumeError(MaybeKind.takeError());
1010 unsigned Kind = MaybeKind.get();
1017 uint32_t tableOffset;
1018 context_block::ContextIDLayout::readRecord(Scratch, tableOffset);
1019 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1021 ContextIDTable.reset(SerializedContextIDTable::Create(
1022 base + tableOffset, base +
sizeof(uint32_t), base));
1028 if (ContextInfoTable)
1031 uint32_t tableOffset;
1032 context_block::ContextInfoLayout::readRecord(Scratch, tableOffset);
1033 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1035 ContextInfoTable.reset(SerializedContextInfoTable::Create(
1036 base + tableOffset, base +
sizeof(uint32_t), base));
1046 MaybeNext = Cursor.advance();
1049 consumeError(MaybeNext.takeError());
1052 Next = MaybeNext.get();
1066 consumeError(MaybeNext.takeError());
1069 llvm::BitstreamEntry Next = MaybeNext.get();
1071 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1072 if (Next.Kind == llvm::BitstreamEntry::Error)
1075 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1078 if (Cursor.SkipBlock())
1081 MaybeNext = Cursor.advance();
1084 consumeError(MaybeNext.takeError());
1087 Next = MaybeNext.get();
1092 llvm::StringRef BlobData;
1094 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1097 consumeError(MaybeKind.takeError());
1100 unsigned Kind = MaybeKind.get();
1104 if (ObjCPropertyTable)
1107 uint32_t tableOffset;
1108 objc_property_block::ObjCPropertyDataLayout::readRecord(Scratch,
1110 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1112 ObjCPropertyTable.reset(SerializedObjCPropertyTable::Create(
1113 base + tableOffset, base +
sizeof(uint32_t), base));
1123 MaybeNext = Cursor.advance();
1126 consumeError(MaybeNext.takeError());
1129 Next = MaybeNext.get();
1143 consumeError(MaybeNext.takeError());
1146 llvm::BitstreamEntry Next = MaybeNext.get();
1147 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1148 if (Next.Kind == llvm::BitstreamEntry::Error)
1151 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1154 if (Cursor.SkipBlock())
1157 MaybeNext = Cursor.advance();
1160 consumeError(MaybeNext.takeError());
1163 Next = MaybeNext.get();
1168 llvm::StringRef BlobData;
1170 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1173 consumeError(MaybeKind.takeError());
1176 unsigned Kind = MaybeKind.get();
1180 if (ObjCMethodTable)
1183 uint32_t tableOffset;
1184 objc_method_block::ObjCMethodDataLayout::readRecord(Scratch, tableOffset);
1185 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1187 ObjCMethodTable.reset(SerializedObjCMethodTable::Create(
1188 base + tableOffset, base +
sizeof(uint32_t), base));
1198 MaybeNext = Cursor.advance();
1201 consumeError(MaybeNext.takeError());
1204 Next = MaybeNext.get();
1218 consumeError(MaybeNext.takeError());
1221 llvm::BitstreamEntry Next = MaybeNext.get();
1222 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1223 if (Next.Kind == llvm::BitstreamEntry::Error)
1226 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1229 if (Cursor.SkipBlock())
1232 MaybeNext = Cursor.advance();
1235 consumeError(MaybeNext.takeError());
1238 Next = MaybeNext.get();
1243 llvm::StringRef BlobData;
1245 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1248 consumeError(MaybeKind.takeError());
1251 unsigned Kind = MaybeKind.get();
1258 uint32_t tableOffset;
1259 cxx_method_block::CXXMethodDataLayout::readRecord(Scratch, tableOffset);
1260 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1262 CXXMethodTable.reset(SerializedCXXMethodTable::Create(
1263 base + tableOffset, base +
sizeof(uint32_t), base));
1273 MaybeNext = Cursor.advance();
1276 consumeError(MaybeNext.takeError());
1279 Next = MaybeNext.get();
1293 consumeError(MaybeNext.takeError());
1296 llvm::BitstreamEntry Next = MaybeNext.get();
1297 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1298 if (Next.Kind == llvm::BitstreamEntry::Error)
1301 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1304 if (Cursor.SkipBlock())
1307 MaybeNext = Cursor.advance();
1310 consumeError(MaybeNext.takeError());
1313 Next = MaybeNext.get();
1318 llvm::StringRef BlobData;
1320 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1323 consumeError(MaybeKind.takeError());
1326 unsigned Kind = MaybeKind.get();
1333 uint32_t tableOffset;
1334 field_block::FieldDataLayout::readRecord(Scratch, tableOffset);
1335 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1337 FieldTable.reset(SerializedFieldTable::Create(
1338 base + tableOffset, base +
sizeof(uint32_t), base));
1348 MaybeNext = Cursor.advance();
1351 consumeError(MaybeNext.takeError());
1354 Next = MaybeNext.get();
1368 consumeError(MaybeNext.takeError());
1371 llvm::BitstreamEntry Next = MaybeNext.get();
1372 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1373 if (Next.Kind == llvm::BitstreamEntry::Error)
1376 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1379 if (Cursor.SkipBlock())
1382 MaybeNext = Cursor.advance();
1385 consumeError(MaybeNext.takeError());
1388 Next = MaybeNext.get();
1393 llvm::StringRef BlobData;
1395 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1398 consumeError(MaybeKind.takeError());
1401 unsigned Kind = MaybeKind.get();
1405 if (ObjCSelectorTable)
1408 uint32_t tableOffset;
1409 objc_selector_block::ObjCSelectorDataLayout::readRecord(Scratch,
1411 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1413 ObjCSelectorTable.reset(SerializedObjCSelectorTable::Create(
1414 base + tableOffset, base +
sizeof(uint32_t), base));
1424 MaybeNext = Cursor.advance();
1427 consumeError(MaybeNext.takeError());
1430 Next = MaybeNext.get();
1444 consumeError(MaybeNext.takeError());
1447 llvm::BitstreamEntry Next = MaybeNext.get();
1448 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1449 if (Next.Kind == llvm::BitstreamEntry::Error)
1452 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1455 if (Cursor.SkipBlock())
1458 MaybeNext = Cursor.advance();
1461 consumeError(MaybeNext.takeError());
1464 Next = MaybeNext.get();
1469 llvm::StringRef BlobData;
1471 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1474 consumeError(MaybeKind.takeError());
1477 unsigned Kind = MaybeKind.get();
1481 if (GlobalVariableTable)
1484 uint32_t tableOffset;
1485 global_variable_block::GlobalVariableDataLayout::readRecord(Scratch,
1487 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1489 GlobalVariableTable.reset(SerializedGlobalVariableTable::Create(
1490 base + tableOffset, base +
sizeof(uint32_t), base));
1500 MaybeNext = Cursor.advance();
1503 consumeError(MaybeNext.takeError());
1506 Next = MaybeNext.get();
1520 consumeError(MaybeNext.takeError());
1523 llvm::BitstreamEntry Next = MaybeNext.get();
1524 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1525 if (Next.Kind == llvm::BitstreamEntry::Error)
1528 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1531 if (Cursor.SkipBlock())
1534 MaybeNext = Cursor.advance();
1537 consumeError(MaybeNext.takeError());
1540 Next = MaybeNext.get();
1545 llvm::StringRef BlobData;
1547 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1550 consumeError(MaybeKind.takeError());
1553 unsigned Kind = MaybeKind.get();
1557 if (GlobalFunctionTable)
1560 uint32_t tableOffset;
1561 global_function_block::GlobalFunctionDataLayout::readRecord(Scratch,
1563 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1565 GlobalFunctionTable.reset(SerializedGlobalFunctionTable::Create(
1566 base + tableOffset, base +
sizeof(uint32_t), base));
1576 MaybeNext = Cursor.advance();
1579 consumeError(MaybeNext.takeError());
1582 Next = MaybeNext.get();
1596 consumeError(MaybeNext.takeError());
1599 llvm::BitstreamEntry Next = MaybeNext.get();
1600 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1601 if (Next.Kind == llvm::BitstreamEntry::Error)
1604 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1607 if (Cursor.SkipBlock())
1610 MaybeNext = Cursor.advance();
1613 consumeError(MaybeNext.takeError());
1616 Next = MaybeNext.get();
1621 llvm::StringRef BlobData;
1623 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1626 consumeError(MaybeKind.takeError());
1629 unsigned Kind = MaybeKind.get();
1633 if (EnumConstantTable)
1636 uint32_t tableOffset;
1637 enum_constant_block::EnumConstantDataLayout::readRecord(Scratch,
1639 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1641 EnumConstantTable.reset(SerializedEnumConstantTable::Create(
1642 base + tableOffset, base +
sizeof(uint32_t), base));
1652 MaybeNext = Cursor.advance();
1655 consumeError(MaybeNext.takeError());
1658 Next = MaybeNext.get();
1672 consumeError(MaybeNext.takeError());
1675 llvm::BitstreamEntry Next = MaybeNext.get();
1676 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1677 if (Next.Kind == llvm::BitstreamEntry::Error)
1680 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1683 if (Cursor.SkipBlock())
1686 MaybeNext = Cursor.advance();
1689 consumeError(MaybeNext.takeError());
1692 Next = MaybeNext.get();
1697 llvm::StringRef BlobData;
1699 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1702 consumeError(MaybeKind.takeError());
1705 unsigned Kind = MaybeKind.get();
1712 uint32_t tableOffset;
1713 tag_block::TagDataLayout::readRecord(Scratch, tableOffset);
1714 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1716 TagTable.reset(SerializedTagTable::Create(base + tableOffset,
1717 base +
sizeof(uint32_t), base));
1727 MaybeNext = Cursor.advance();
1730 consumeError(MaybeNext.takeError());
1733 Next = MaybeNext.get();
1747 consumeError(MaybeNext.takeError());
1750 llvm::BitstreamEntry Next = MaybeNext.get();
1751 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1752 if (Next.Kind == llvm::BitstreamEntry::Error)
1755 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1758 if (Cursor.SkipBlock())
1761 MaybeNext = Cursor.advance();
1764 consumeError(MaybeNext.takeError());
1767 Next = MaybeNext.get();
1772 llvm::StringRef BlobData;
1774 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1777 consumeError(MaybeKind.takeError());
1780 unsigned Kind = MaybeKind.get();
1787 uint32_t tableOffset;
1788 typedef_block::TypedefDataLayout::readRecord(Scratch, tableOffset);
1789 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1791 TypedefTable.reset(SerializedTypedefTable::Create(
1792 base + tableOffset, base +
sizeof(uint32_t), base));
1802 MaybeNext = Cursor.advance();
1805 consumeError(MaybeNext.takeError());
1808 Next = MaybeNext.get();
1814APINotesReader::APINotesReader(llvm::MemoryBuffer *InputBuffer,
1815 llvm::VersionTuple SwiftVersion,
bool &Failed)
1826 if (Cursor.AtEndOfStream()) {
1832 if (maybeRead.get() !=
byte) {
1838 consumeError(maybeRead.takeError());
1845 bool HasValidControlBlock =
false;
1847 while (!
Cursor.AtEndOfStream()) {
1849 if (!MaybeTopLevelEntry) {
1851 consumeError(MaybeTopLevelEntry.takeError());
1855 llvm::BitstreamEntry TopLevelEntry = MaybeTopLevelEntry.get();
1857 if (TopLevelEntry.Kind != llvm::BitstreamEntry::SubBlock)
1860 switch (TopLevelEntry.ID) {
1861 case llvm::bitc::BLOCKINFO_BLOCK_ID:
1862 if (!
Cursor.ReadBlockInfoBlock()) {
1870 if (HasValidControlBlock ||
1871 Implementation->readControlBlock(Cursor, Scratch)) {
1876 HasValidControlBlock =
true;
1880 if (!HasValidControlBlock ||
1881 Implementation->readIdentifierBlock(Cursor, Scratch)) {
1888 if (!HasValidControlBlock ||
1889 Implementation->readContextBlock(Cursor, Scratch)) {
1897 if (!HasValidControlBlock ||
1898 Implementation->readObjCPropertyBlock(Cursor, Scratch)) {
1905 if (!HasValidControlBlock ||
1906 Implementation->readObjCMethodBlock(Cursor, Scratch)) {
1913 if (!HasValidControlBlock ||
1914 Implementation->readCXXMethodBlock(Cursor, Scratch)) {
1921 if (!HasValidControlBlock ||
1922 Implementation->readFieldBlock(Cursor, Scratch)) {
1929 if (!HasValidControlBlock ||
1930 Implementation->readObjCSelectorBlock(Cursor, Scratch)) {
1937 if (!HasValidControlBlock ||
1938 Implementation->readGlobalVariableBlock(Cursor, Scratch)) {
1945 if (!HasValidControlBlock ||
1946 Implementation->readGlobalFunctionBlock(Cursor, Scratch)) {
1953 if (!HasValidControlBlock ||
1954 Implementation->readEnumConstantBlock(Cursor, Scratch)) {
1961 if (!HasValidControlBlock ||
1962 Implementation->readTagBlock(Cursor, Scratch)) {
1969 if (!HasValidControlBlock ||
1970 Implementation->readTypedefBlock(Cursor, Scratch)) {
1979 if (
Cursor.SkipBlock()) {
1987 if (!
Cursor.AtEndOfStream()) {
1995std::unique_ptr<APINotesReader>
1997 llvm::VersionTuple SwiftVersion) {
1998 bool Failed =
false;
1999 std::unique_ptr<APINotesReader> Reader(
2000 new APINotesReader(InputBuffer.release(), SwiftVersion, Failed));
2007template <
typename T>
2009 llvm::VersionTuple Version,
2011 : Results(
std::move(R)) {
2013 assert(!Results.empty());
2014 assert(std::is_sorted(
2015 Results.begin(), Results.end(),
2016 [](
const std::pair<llvm::VersionTuple, T> &left,
2017 const std::pair<llvm::VersionTuple, T> &right) ->
bool {
2018 assert(left.first != right.first &&
"two entries for the same version");
2019 return left.first < right.first;
2022 Selected = std::nullopt;
2023 for (
unsigned i = 0, n = Results.size(); i != n; ++i) {
2024 if (!Version.empty() && Results[i].first >= Version) {
2036 if (!Selected && Results[0].first.empty())
2041 -> std::optional<ContextID> {
2043 return std::nullopt;
2047 return std::nullopt;
2054 return std::nullopt;
2062 return std::nullopt;
2066 return std::nullopt;
2070 return std::nullopt;
2076 -> std::optional<ContextID> {
2078 return std::nullopt;
2082 return std::nullopt;
2089 return std::nullopt;
2097 return std::nullopt;
2101 return std::nullopt;
2105 return std::nullopt;
2114 return std::nullopt;
2118 return std::nullopt;
2121 std::make_tuple(CtxID.Value, *PropertyID, (
char)IsInstance));
2123 return std::nullopt;
2129 bool IsInstanceMethod)
2132 return std::nullopt;
2136 return std::nullopt;
2139 ObjCMethodTableInfo::internal_key_type{CtxID.Value, *SelID,
2142 return std::nullopt;
2150 return std::nullopt;
2154 return std::nullopt;
2159 return std::nullopt;
2167 return std::nullopt;
2171 return std::nullopt;
2176 return std::nullopt;
2182 std::optional<Context> Ctx)
2185 return std::nullopt;
2189 return std::nullopt;
2195 return std::nullopt;
2201 std::optional<Context> Ctx)
2204 return std::nullopt;
2208 return std::nullopt;
2214 return std::nullopt;
2222 return std::nullopt;
2226 return std::nullopt;
2230 return std::nullopt;
2236 std::optional<Context> ParentCtx)
2237 -> std::optional<ContextID> {
2239 return std::nullopt;
2243 return std::nullopt;
2248 return std::nullopt;
2256 return std::nullopt;
2260 return std::nullopt;
2266 return std::nullopt;
2272 std::optional<Context> Ctx)
2275 return std::nullopt;
2279 return std::nullopt;
2285 return std::nullopt;
2291 llvm::StringRef Name, std::optional<ContextID> ParentNamespaceID)
2292 -> std::optional<ContextID> {
2294 return std::nullopt;
2298 return std::nullopt;
2300 uint32_t RawParentNamespaceID =
2301 ParentNamespaceID ? ParentNamespaceID->Value : -1;
2305 return std::nullopt;
static StringRef getIdentifier(const Token &Tok)
Implements an efficient mapping from strings to IdentifierInfo nodes.
iterator find(StringRef Name) const
Smart pointer class that efficiently represents Objective-C method names.
llvm::OnDiskIterableChainedHashTable< FieldTableInfo > SerializedFieldTable
llvm::OnDiskIterableChainedHashTable< GlobalVariableTableInfo > SerializedGlobalVariableTable
std::unique_ptr< SerializedContextIDTable > ContextIDTable
The Objective-C / C++ context ID table.
bool readEnumConstantBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
std::string ModuleName
The name of the module that we read from the control block.
std::optional< std::pair< off_t, time_t > > SourceFileSizeAndModTime
std::unique_ptr< SerializedIdentifierTable > IdentifierTable
The identifier table.
llvm::OnDiskIterableChainedHashTable< TagTableInfo > SerializedTagTable
std::unique_ptr< SerializedGlobalFunctionTable > GlobalFunctionTable
The global function table.
std::unique_ptr< SerializedObjCPropertyTable > ObjCPropertyTable
The Objective-C property table.
bool readObjCMethodBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
std::unique_ptr< SerializedGlobalVariableTable > GlobalVariableTable
The global variable table.
bool readTagBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
std::unique_ptr< SerializedTypedefTable > TypedefTable
The typedef table.
bool readFieldBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
llvm::OnDiskIterableChainedHashTable< ObjCSelectorTableInfo > SerializedObjCSelectorTable
bool readGlobalFunctionBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
bool readTypedefBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
llvm::MemoryBuffer * InputBuffer
The input buffer for the API notes data.
std::unique_ptr< SerializedObjCSelectorTable > ObjCSelectorTable
The Objective-C selector table.
bool readControlBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
std::unique_ptr< SerializedCXXMethodTable > CXXMethodTable
The C++ method table.
bool readObjCPropertyBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
bool readObjCSelectorBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
llvm::OnDiskIterableChainedHashTable< IdentifierTableInfo > SerializedIdentifierTable
std::unique_ptr< SerializedEnumConstantTable > EnumConstantTable
The enumerator table.
std::optional< IdentifierID > getIdentifier(llvm::StringRef Str)
Retrieve the identifier ID for the given string, or an empty optional if the string is unknown.
bool readGlobalVariableBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
llvm::OnDiskIterableChainedHashTable< ObjCPropertyTableInfo > SerializedObjCPropertyTable
std::unique_ptr< SerializedTagTable > TagTable
The tag table.
llvm::OnDiskIterableChainedHashTable< CXXMethodTableInfo > SerializedCXXMethodTable
std::unique_ptr< SerializedFieldTable > FieldTable
The C record field table.
std::optional< SelectorID > getSelector(ObjCSelectorRef Selector)
Retrieve the selector ID for the given selector, or an empty optional if the string is unknown.
llvm::OnDiskIterableChainedHashTable< ObjCMethodTableInfo > SerializedObjCMethodTable
bool readCXXMethodBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
bool readIdentifierBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
llvm::VersionTuple SwiftVersion
The Swift version to use for filtering.
bool readContextBlock(llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl< uint64_t > &Scratch)
llvm::OnDiskIterableChainedHashTable< EnumConstantTableInfo > SerializedEnumConstantTable
std::unique_ptr< SerializedObjCMethodTable > ObjCMethodTable
The Objective-C method table.
std::unique_ptr< SerializedContextInfoTable > ContextInfoTable
The Objective-C context info table.
llvm::OnDiskIterableChainedHashTable< TypedefTableInfo > SerializedTypedefTable
llvm::OnDiskIterableChainedHashTable< GlobalFunctionTableInfo > SerializedGlobalFunctionTable
llvm::OnDiskIterableChainedHashTable< ContextInfoTableInfo > SerializedContextInfoTable
llvm::OnDiskIterableChainedHashTable< ContextIDTableInfo > SerializedContextIDTable
Captures the completed versioned information for a particular part of API notes, including both unver...
VersionedInfo(std::nullopt_t)
Form an empty set of versioned information.
A class that reads API notes data from a binary file that was written by the APINotesWriter.
VersionedInfo< ContextInfo > lookupObjCClassInfo(llvm::StringRef Name)
Look for information regarding the given Objective-C class.
VersionedInfo< FieldInfo > lookupField(ContextID CtxID, llvm::StringRef Name)
Look for information regarding the given field of a C struct.
VersionedInfo< CXXMethodInfo > lookupCXXMethod(ContextID CtxID, llvm::StringRef Name)
Look for information regarding the given C++ method in the given C++ tag context.
VersionedInfo< TagInfo > lookupTag(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given tag (struct/union/enum/C++ class).
VersionedInfo< GlobalFunctionInfo > lookupGlobalFunction(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given global function.
VersionedInfo< ObjCPropertyInfo > lookupObjCProperty(ContextID CtxID, llvm::StringRef Name, bool IsInstance)
Look for information regarding the given Objective-C property in the given context.
VersionedInfo< ObjCMethodInfo > lookupObjCMethod(ContextID CtxID, ObjCSelectorRef Selector, bool IsInstanceMethod)
Look for information regarding the given Objective-C method in the given context.
VersionedInfo< GlobalVariableInfo > lookupGlobalVariable(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given global variable.
std::optional< ContextID > lookupNamespaceID(llvm::StringRef Name, std::optional< ContextID > ParentNamespaceID=std::nullopt)
Look for the context ID of the given C++ namespace.
std::optional< ContextID > lookupTagID(llvm::StringRef Name, std::optional< Context > ParentCtx=std::nullopt)
Look for the context ID of the given C++ tag.
VersionedInfo< TypedefInfo > lookupTypedef(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given typedef.
std::optional< ContextID > lookupObjCClassID(llvm::StringRef Name)
Look for the context ID of the given Objective-C class.
static std::unique_ptr< APINotesReader > Create(std::unique_ptr< llvm::MemoryBuffer > InputBuffer, llvm::VersionTuple SwiftVersion)
Create a new API notes reader from the given member buffer, which contains the contents of a binary A...
VersionedInfo< ContextInfo > lookupObjCProtocolInfo(llvm::StringRef Name)
Look for information regarding the given Objective-C protocol.
std::optional< ContextID > lookupObjCProtocolID(llvm::StringRef Name)
Look for the context ID of the given Objective-C protocol.
VersionedInfo< EnumConstantInfo > lookupEnumConstant(llvm::StringRef Name)
Look for information regarding the given enumerator.
Opaque context ID used to refer to an Objective-C class or protocol or a C++ namespace.
llvm::PointerEmbeddedInt< unsigned, 31 > SelectorID
const uint8_t kSwiftCopyable
RetainCountConventionKind
llvm::PointerEmbeddedInt< unsigned, 31 > IdentifierID
SwiftNewTypeKind
The kind of a swift_wrapper/swift_newtype.
const uint8_t kSwiftNonCopyable
EnumExtensibilityKind
The payload for an enum_extensibility attribute.
const uint16_t VERSION_MAJOR
API notes file major version number.
const unsigned char API_NOTES_SIGNATURE[]
Magic number for API notes files.
const uint16_t VERSION_MINOR
API notes file minor version number.
@ OBJC_CONTEXT_BLOCK_ID
The Objective-C context data block, which contains information about Objective-C classes and protocol...
@ TYPEDEF_BLOCK_ID
The typedef data block, which maps typedef names to information about the typedefs.
@ OBJC_PROPERTY_BLOCK_ID
The Objective-C property data block, which maps Objective-C (class name, property name) pairs to info...
@ ENUM_CONSTANT_BLOCK_ID
The enum constant data block, which maps enumerator names to information about the enumerators.
@ TAG_BLOCK_ID
The tag data block, which maps tag names to information about the tags.
@ OBJC_METHOD_BLOCK_ID
The Objective-C property data block, which maps Objective-C (class name, selector,...
@ FIELD_BLOCK_ID
The fields data block, which maps names fields of C records to information about the field.
@ OBJC_SELECTOR_BLOCK_ID
The Objective-C selector data block, which maps Objective-C selector names (# of pieces,...
@ CXX_METHOD_BLOCK_ID
The C++ method data block, which maps C++ (context id, method name) pairs to information about the me...
@ GLOBAL_FUNCTION_BLOCK_ID
The (global) functions data block, which maps global function names to information about the global f...
@ CONTROL_BLOCK_ID
The control block, which contains all of the information that needs to be validated prior to committi...
@ IDENTIFIER_BLOCK_ID
The identifier data block, which maps identifier strings to IDs.
@ GLOBAL_VARIABLE_BLOCK_ID
The global variables data block, which maps global variable names to information about the global var...
unsigned ComputeHash(Selector Sel)
The JSON file list parser is used to communicate input to InstallAPI.
NullabilityKind
Describes the nullability of a particular type.
@ Result
The result type of a method or function.
hash_code hash_value(const clang::tooling::dependencies::ModuleID &ID)
A stored Objective-C or C++ context, represented by the ID of its parent context, the kind of this co...
A temporary reference to an Objective-C selector, suitable for referencing selector data on the stack...
A stored Objective-C or C++ declaration, represented by the ID of its parent context,...
A stored Objective-C selector.
llvm::SmallVector< IdentifierID, 2 > Identifiers