18#include "llvm/ADT/Hashing.h"
19#include "llvm/ADT/StringExtras.h"
20#include "llvm/Bitstream/BitstreamReader.h"
21#include "llvm/Support/DJB.h"
22#include "llvm/Support/EndianStream.h"
23#include "llvm/Support/OnDiskHashTable.h"
27using namespace llvm::support;
31llvm::VersionTuple ReadVersionTuple(
const uint8_t *&
Data) {
32 uint8_t NumVersions = (*
Data++) & 0x03;
34 unsigned Major = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
36 return llvm::VersionTuple(Major);
38 unsigned Minor = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
40 return llvm::VersionTuple(Major, Minor);
43 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
45 return llvm::VersionTuple(Major, Minor, Subminor);
47 unsigned Build = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
48 return llvm::VersionTuple(Major, Minor, Subminor, Build);
52template <
typename Derived,
typename KeyType,
typename UnversionedDataType>
53class VersionedTableInfo {
55 using internal_key_type = KeyType;
56 using external_key_type = KeyType;
59 using hash_value_type =
size_t;
62 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
64 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
66 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
70 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
72 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
74 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
75 return {KeyLength, DataLength};
78 static data_type ReadData(internal_key_type Key,
const uint8_t *
Data,
80 unsigned NumElements =
81 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
83 Result.reserve(NumElements);
84 for (
unsigned i = 0; i != NumElements; ++i) {
85 auto version = ReadVersionTuple(
Data);
86 const auto *DataBefore =
Data;
88 auto UnversionedData = Derived::readUnversioned(Key,
Data);
89 assert(
Data != DataBefore &&
90 "Unversioned data reader didn't move pointer");
91 Result.push_back({version, UnversionedData});
98void ReadCommonEntityInfo(
const uint8_t *&
Data, CommonEntityInfo &Info) {
99 uint8_t UnavailableBits = *
Data++;
100 Info.Unavailable = (UnavailableBits >> 1) & 0x01;
101 Info.UnavailableInSwift = UnavailableBits & 0x01;
102 if ((UnavailableBits >> 2) & 0x01)
103 Info.setSwiftPrivate(
static_cast<bool>((UnavailableBits >> 3) & 0x01));
106 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
107 Info.UnavailableMsg =
108 std::string(
reinterpret_cast<const char *
>(
Data),
109 reinterpret_cast<const char *
>(
Data) + MsgLength);
112 unsigned SwiftNameLength =
113 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
115 std::string(
reinterpret_cast<const char *
>(
Data),
116 reinterpret_cast<const char *
>(
Data) + SwiftNameLength);
117 Data += SwiftNameLength;
121void ReadCommonTypeInfo(
const uint8_t *&
Data, CommonTypeInfo &Info) {
122 ReadCommonEntityInfo(
Data, Info);
124 unsigned SwiftBridgeLength =
125 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
126 if (SwiftBridgeLength > 0) {
127 Info.setSwiftBridge(std::string(
reinterpret_cast<const char *
>(
Data),
128 SwiftBridgeLength - 1));
129 Data += SwiftBridgeLength - 1;
132 unsigned ErrorDomainLength =
133 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
134 if (ErrorDomainLength > 0) {
135 Info.setNSErrorDomain(std::optional<std::string>(std::string(
136 reinterpret_cast<const char *
>(
Data), ErrorDomainLength - 1)));
137 Data += ErrorDomainLength - 1;
142class IdentifierTableInfo {
144 using internal_key_type = llvm::StringRef;
145 using external_key_type = llvm::StringRef;
150 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
152 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
154 hash_value_type
ComputeHash(internal_key_type Key) {
155 return llvm::djbHash(Key);
158 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
162 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
164 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
165 unsigned DataLength =
166 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
167 return {KeyLength, DataLength};
170 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
171 return llvm::StringRef(
reinterpret_cast<const char *
>(
Data), Length);
174 static data_type ReadData(internal_key_type key,
const uint8_t *
Data,
176 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
182class ContextIDTableInfo {
184 using internal_key_type = ContextTableKey;
185 using external_key_type = internal_key_type;
187 using hash_value_type =
size_t;
190 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
192 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
194 hash_value_type
ComputeHash(internal_key_type Key) {
195 return static_cast<size_t>(Key.hashValue());
198 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
202 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
204 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
205 unsigned DataLength =
206 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
207 return {KeyLength, DataLength};
210 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
212 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
214 endian::readNext<uint8_t, llvm::endianness::little>(
Data);
215 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
219 static data_type ReadData(internal_key_type Key,
const uint8_t *
Data,
221 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
226class ContextInfoTableInfo
227 :
public VersionedTableInfo<ContextInfoTableInfo, unsigned, ContextInfo> {
229 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
230 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
233 hash_value_type
ComputeHash(internal_key_type Key) {
237 static ContextInfo readUnversioned(internal_key_type Key,
238 const uint8_t *&
Data) {
240 ReadCommonTypeInfo(
Data, Info);
241 uint8_t Payload = *
Data++;
244 Info.setHasDesignatedInits(
true);
245 Payload = Payload >> 1;
248 Info.setDefaultNullability(
static_cast<NullabilityKind>(Payload & 0x03));
251 if (Payload & (1 << 1))
252 Info.setSwiftObjCMembers(Payload & 1);
255 if (Payload & (1 << 1))
256 Info.setSwiftImportAsNonGeneric(Payload & 1);
263void ReadVariableInfo(
const uint8_t *&
Data, VariableInfo &Info) {
264 ReadCommonEntityInfo(
Data, Info);
270 auto TypeLen = endian::readNext<uint16_t, llvm::endianness::little>(
Data);
271 Info.setType(std::string(
Data,
Data + TypeLen));
276class ObjCPropertyTableInfo
277 :
public VersionedTableInfo<ObjCPropertyTableInfo,
278 std::tuple<uint32_t, uint32_t, uint8_t>,
281 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
282 auto ClassID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
283 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
284 char IsInstance = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
285 return {ClassID, NameID, IsInstance};
288 hash_value_type
ComputeHash(internal_key_type Key) {
292 static ObjCPropertyInfo readUnversioned(internal_key_type Key,
293 const uint8_t *&
Data) {
294 ObjCPropertyInfo Info;
295 ReadVariableInfo(
Data, Info);
296 uint8_t Flags = *
Data++;
297 if (Flags & (1 << 0))
298 Info.setSwiftImportAsAccessors(Flags & (1 << 1));
305 :
public VersionedTableInfo<FieldTableInfo, SingleDeclTableKey, FieldInfo> {
307 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
308 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
309 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
310 return {CtxID, NameID};
313 hash_value_type
ComputeHash(internal_key_type Key) {
314 return static_cast<size_t>(Key.hashValue());
317 static FieldInfo readUnversioned(internal_key_type Key,
318 const uint8_t *&
Data) {
320 ReadVariableInfo(
Data, Info);
326void ReadParamInfo(
const uint8_t *&
Data, ParamInfo &Info) {
327 ReadVariableInfo(
Data, Info);
329 uint8_t Payload = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
330 if (
auto RawConvention = Payload & 0x7) {
332 Info.setRetainCountConvention(Convention);
336 Info.setLifetimebound(Payload & 0x02);
339 Info.setNoEscape(Payload & 0x02);
341 assert(Payload == 0 &&
"Bad API notes");
345void ReadFunctionInfo(
const uint8_t *&
Data, FunctionInfo &Info) {
346 ReadCommonEntityInfo(
Data, Info);
348 uint8_t Payload = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
349 if (
auto RawConvention = Payload & 0x7) {
351 Info.setRetainCountConvention(Convention);
354 Info.NullabilityAudited = Payload & 0x1;
356 assert(Payload == 0 &&
"Bad API notes");
358 Info.NumAdjustedNullable =
359 endian::readNext<uint8_t, llvm::endianness::little>(
Data);
360 Info.NullabilityPayload =
361 endian::readNext<uint64_t, llvm::endianness::little>(
Data);
364 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
365 while (NumParams > 0) {
367 ReadParamInfo(
Data, pi);
368 Info.Params.push_back(pi);
372 unsigned ResultTypeLen =
373 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
374 Info.ResultType = std::string(
Data,
Data + ResultTypeLen);
375 Data += ResultTypeLen;
377 unsigned SwiftReturnOwnershipLength =
378 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
379 Info.SwiftReturnOwnership = std::string(
reinterpret_cast<const char *
>(
Data),
380 reinterpret_cast<const char *
>(
Data) +
381 SwiftReturnOwnershipLength);
382 Data += SwiftReturnOwnershipLength;
386class ObjCMethodTableInfo
387 :
public VersionedTableInfo<ObjCMethodTableInfo,
388 std::tuple<uint32_t, uint32_t, uint8_t>,
391 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
392 auto ClassID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
394 endian::readNext<uint32_t, llvm::endianness::little>(
Data);
395 auto IsInstance = endian::readNext<uint8_t, llvm::endianness::little>(
Data);
399 hash_value_type
ComputeHash(internal_key_type Key) {
403 static ObjCMethodInfo readUnversioned(internal_key_type Key,
404 const uint8_t *&
Data) {
406 uint8_t Payload = *
Data++;
407 bool HasSelf = Payload & 0x01;
409 Info.RequiredInit = Payload & 0x01;
411 Info.DesignatedInit = Payload & 0x01;
413 assert(Payload == 0 &&
"Unable to fully decode 'Payload'.");
415 ReadFunctionInfo(
Data, Info);
417 Info.Self = ParamInfo{};
418 ReadParamInfo(
Data, *Info.Self);
425class ObjCSelectorTableInfo {
427 using internal_key_type = StoredObjCSelector;
428 using external_key_type = internal_key_type;
433 internal_key_type GetInternalKey(external_key_type Key) {
return Key; }
435 external_key_type GetExternalKey(internal_key_type Key) {
return Key; }
437 hash_value_type
ComputeHash(internal_key_type Key) {
438 return llvm::DenseMapInfo<StoredObjCSelector>::getHashValue(Key);
441 static bool EqualKey(internal_key_type LHS, internal_key_type RHS) {
442 return llvm::DenseMapInfo<StoredObjCSelector>::isEqual(LHS, RHS);
445 static std::pair<unsigned, unsigned> ReadKeyDataLength(
const uint8_t *&
Data) {
447 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
448 unsigned DataLength =
449 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
450 return {KeyLength, DataLength};
453 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
454 internal_key_type Key;
455 Key.NumArgs = endian::readNext<uint16_t, llvm::endianness::little>(
Data);
456 unsigned NumIdents = (Length -
sizeof(uint16_t)) /
sizeof(
uint32_t);
457 for (
unsigned i = 0; i != NumIdents; ++i) {
458 Key.Identifiers.push_back(
459 endian::readNext<uint32_t, llvm::endianness::little>(
Data));
464 static data_type ReadData(internal_key_type Key,
const uint8_t *
Data,
466 return endian::readNext<uint32_t, llvm::endianness::little>(
Data);
471class GlobalVariableTableInfo
472 :
public VersionedTableInfo<GlobalVariableTableInfo, SingleDeclTableKey,
473 GlobalVariableInfo> {
475 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
476 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
477 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
478 return {CtxID, NameID};
481 hash_value_type
ComputeHash(internal_key_type Key) {
482 return static_cast<size_t>(Key.hashValue());
485 static GlobalVariableInfo readUnversioned(internal_key_type Key,
486 const uint8_t *&
Data) {
487 GlobalVariableInfo Info;
488 ReadVariableInfo(
Data, Info);
494class GlobalFunctionTableInfo
495 :
public VersionedTableInfo<GlobalFunctionTableInfo, SingleDeclTableKey,
496 GlobalFunctionInfo> {
498 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
499 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
500 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
501 return {CtxID, NameID};
504 hash_value_type
ComputeHash(internal_key_type Key) {
505 return static_cast<size_t>(Key.hashValue());
508 static GlobalFunctionInfo readUnversioned(internal_key_type Key,
509 const uint8_t *&
Data) {
510 GlobalFunctionInfo Info;
511 ReadFunctionInfo(
Data, Info);
517class CXXMethodTableInfo
518 :
public VersionedTableInfo<CXXMethodTableInfo, SingleDeclTableKey,
521 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
522 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
523 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
524 return {CtxID, NameID};
527 hash_value_type
ComputeHash(internal_key_type Key) {
528 return static_cast<size_t>(Key.hashValue());
531 static CXXMethodInfo readUnversioned(internal_key_type Key,
532 const uint8_t *&
Data) {
535 uint8_t Payload = *
Data++;
536 bool HasThis = Payload & 0x01;
538 assert(Payload == 0 &&
"Unable to fully decode 'Payload'.");
540 ReadFunctionInfo(
Data, Info);
542 Info.This = ParamInfo{};
543 ReadParamInfo(
Data, *Info.This);
550class EnumConstantTableInfo
551 :
public VersionedTableInfo<EnumConstantTableInfo, uint32_t,
554 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
555 auto NameID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
559 hash_value_type
ComputeHash(internal_key_type Key) {
563 static EnumConstantInfo readUnversioned(internal_key_type Key,
564 const uint8_t *&
Data) {
565 EnumConstantInfo Info;
566 ReadCommonEntityInfo(
Data, Info);
573 :
public VersionedTableInfo<TagTableInfo, SingleDeclTableKey, TagInfo> {
575 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
576 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
578 endian::readNext<IdentifierID, llvm::endianness::little>(
Data);
579 return {CtxID, NameID};
582 hash_value_type
ComputeHash(internal_key_type Key) {
583 return static_cast<size_t>(Key.hashValue());
586 static TagInfo readUnversioned(internal_key_type Key,
const uint8_t *&
Data) {
589 uint8_t Payload = *
Data++;
591 Info.setFlagEnum(Payload & 2);
594 Info.EnumExtensibility =
598 endian::readNext<uint8_t, llvm::endianness::little>(
Data);
602 endian::readNext<uint8_t, llvm::endianness::little>(
Data);
604 Info.setSwiftEscapable(std::optional(Escapable ==
kSwiftConforms));
606 unsigned ImportAsLength =
607 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
608 if (ImportAsLength > 0) {
610 std::string(
reinterpret_cast<const char *
>(
Data), ImportAsLength - 1);
611 Data += ImportAsLength - 1;
613 unsigned RetainOpLength =
614 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
615 if (RetainOpLength > 0) {
617 std::string(
reinterpret_cast<const char *
>(
Data), RetainOpLength - 1);
618 Data += RetainOpLength - 1;
620 unsigned ReleaseOpLength =
621 endian::readNext<uint16_t, llvm::endianness::little>(
Data);
622 if (ReleaseOpLength > 0) {
623 Info.SwiftReleaseOp = std::string(
reinterpret_cast<const char *
>(
Data),
624 ReleaseOpLength - 1);
625 Data += ReleaseOpLength - 1;
627 if (
unsigned ConformanceLength =
628 endian::readNext<uint16_t, llvm::endianness::little>(
Data)) {
629 Info.SwiftConformance = std::string(
reinterpret_cast<const char *
>(
Data),
630 ConformanceLength - 1);
631 Data += ConformanceLength - 1;
634 ReadCommonTypeInfo(
Data, Info);
640class TypedefTableInfo
641 :
public VersionedTableInfo<TypedefTableInfo, SingleDeclTableKey,
644 static internal_key_type ReadKey(
const uint8_t *
Data,
unsigned Length) {
645 auto CtxID = endian::readNext<uint32_t, llvm::endianness::little>(
Data);
647 endian::readNext<IdentifierID, llvm::endianness::little>(
Data);
648 return {CtxID, nameID};
651 hash_value_type
ComputeHash(internal_key_type Key) {
652 return static_cast<size_t>(Key.hashValue());
655 static TypedefInfo readUnversioned(internal_key_type Key,
656 const uint8_t *&
Data) {
659 uint8_t Payload = *
Data++;
663 ReadCommonTypeInfo(
Data, Info);
685 llvm::OnDiskIterableChainedHashTable<IdentifierTableInfo>;
691 llvm::OnDiskIterableChainedHashTable<ContextIDTableInfo>;
697 llvm::OnDiskIterableChainedHashTable<ContextInfoTableInfo>;
703 llvm::OnDiskIterableChainedHashTable<ObjCPropertyTableInfo>;
709 llvm::OnDiskIterableChainedHashTable<FieldTableInfo>;
715 llvm::OnDiskIterableChainedHashTable<ObjCMethodTableInfo>;
721 llvm::OnDiskIterableChainedHashTable<CXXMethodTableInfo>;
727 llvm::OnDiskIterableChainedHashTable<ObjCSelectorTableInfo>;
733 llvm::OnDiskIterableChainedHashTable<GlobalVariableTableInfo>;
739 llvm::OnDiskIterableChainedHashTable<GlobalFunctionTableInfo>;
745 llvm::OnDiskIterableChainedHashTable<EnumConstantTableInfo>;
756 llvm::OnDiskIterableChainedHashTable<TypedefTableInfo>;
763 std::optional<IdentifierID>
getIdentifier(llvm::StringRef Str);
797std::optional<IdentifierID>
812std::optional<SelectorID>
820 for (
auto Ident :
Selector.Identifiers) {
828 auto Known = ObjCSelectorTable->find(Key);
829 if (Known == ObjCSelectorTable->end())
840 bool SawMetadata =
false;
845 consumeError(MaybeNext.takeError());
848 llvm::BitstreamEntry Next = MaybeNext.get();
850 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
851 if (Next.Kind == llvm::BitstreamEntry::Error)
854 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
857 if (Cursor.SkipBlock())
860 MaybeNext = Cursor.advance();
863 consumeError(MaybeNext.takeError());
866 Next = MaybeNext.get();
871 llvm::StringRef BlobData;
873 Cursor.readRecord(Next.ID, Scratch, &BlobData);
876 consumeError(MaybeKind.takeError());
879 unsigned Kind = MaybeKind.get();
894 ModuleName = BlobData.str();
901 SourceFileSizeAndModTime = {Scratch[0], Scratch[1]};
910 MaybeNext = Cursor.advance();
913 consumeError(MaybeNext.takeError());
916 Next = MaybeNext.get();
930 consumeError(MaybeNext.takeError());
933 llvm::BitstreamEntry Next = MaybeNext.get();
935 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
936 if (Next.Kind == llvm::BitstreamEntry::Error)
939 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
942 if (Cursor.SkipBlock())
945 MaybeNext = Cursor.advance();
948 consumeError(MaybeNext.takeError());
951 Next = MaybeNext.get();
956 llvm::StringRef BlobData;
958 Cursor.readRecord(Next.ID, Scratch, &BlobData);
961 consumeError(MaybeKind.takeError());
964 unsigned Kind = MaybeKind.get();
971 uint32_t tableOffset;
972 identifier_block::IdentifierDataLayout::readRecord(Scratch, tableOffset);
973 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
976 base + tableOffset, base +
sizeof(uint32_t), base));
986 MaybeNext = Cursor.advance();
989 consumeError(MaybeNext.takeError());
992 Next = MaybeNext.get();
1006 consumeError(MaybeNext.takeError());
1009 llvm::BitstreamEntry Next = MaybeNext.get();
1011 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1012 if (Next.Kind == llvm::BitstreamEntry::Error)
1015 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1018 if (Cursor.SkipBlock())
1021 MaybeNext = Cursor.advance();
1024 consumeError(MaybeNext.takeError());
1027 Next = MaybeNext.get();
1032 llvm::StringRef BlobData;
1034 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1037 consumeError(MaybeKind.takeError());
1040 unsigned Kind = MaybeKind.get();
1047 uint32_t tableOffset;
1048 context_block::ContextIDLayout::readRecord(Scratch, tableOffset);
1049 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1051 ContextIDTable.reset(SerializedContextIDTable::Create(
1052 base + tableOffset, base +
sizeof(uint32_t), base));
1058 if (ContextInfoTable)
1061 uint32_t tableOffset;
1062 context_block::ContextInfoLayout::readRecord(Scratch, tableOffset);
1063 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1065 ContextInfoTable.reset(SerializedContextInfoTable::Create(
1066 base + tableOffset, base +
sizeof(uint32_t), base));
1076 MaybeNext = Cursor.advance();
1079 consumeError(MaybeNext.takeError());
1082 Next = MaybeNext.get();
1096 consumeError(MaybeNext.takeError());
1099 llvm::BitstreamEntry Next = MaybeNext.get();
1101 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1102 if (Next.Kind == llvm::BitstreamEntry::Error)
1105 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1108 if (Cursor.SkipBlock())
1111 MaybeNext = Cursor.advance();
1114 consumeError(MaybeNext.takeError());
1117 Next = MaybeNext.get();
1122 llvm::StringRef BlobData;
1124 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1127 consumeError(MaybeKind.takeError());
1130 unsigned Kind = MaybeKind.get();
1134 if (ObjCPropertyTable)
1137 uint32_t tableOffset;
1138 objc_property_block::ObjCPropertyDataLayout::readRecord(Scratch,
1140 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1142 ObjCPropertyTable.reset(SerializedObjCPropertyTable::Create(
1143 base + tableOffset, base +
sizeof(uint32_t), base));
1153 MaybeNext = Cursor.advance();
1156 consumeError(MaybeNext.takeError());
1159 Next = MaybeNext.get();
1173 consumeError(MaybeNext.takeError());
1176 llvm::BitstreamEntry Next = MaybeNext.get();
1177 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1178 if (Next.Kind == llvm::BitstreamEntry::Error)
1181 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1184 if (Cursor.SkipBlock())
1187 MaybeNext = Cursor.advance();
1190 consumeError(MaybeNext.takeError());
1193 Next = MaybeNext.get();
1198 llvm::StringRef BlobData;
1200 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1203 consumeError(MaybeKind.takeError());
1206 unsigned Kind = MaybeKind.get();
1210 if (ObjCMethodTable)
1213 uint32_t tableOffset;
1214 objc_method_block::ObjCMethodDataLayout::readRecord(Scratch, tableOffset);
1215 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1217 ObjCMethodTable.reset(SerializedObjCMethodTable::Create(
1218 base + tableOffset, base +
sizeof(uint32_t), base));
1228 MaybeNext = Cursor.advance();
1231 consumeError(MaybeNext.takeError());
1234 Next = MaybeNext.get();
1248 consumeError(MaybeNext.takeError());
1251 llvm::BitstreamEntry Next = MaybeNext.get();
1252 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1253 if (Next.Kind == llvm::BitstreamEntry::Error)
1256 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1259 if (Cursor.SkipBlock())
1262 MaybeNext = Cursor.advance();
1265 consumeError(MaybeNext.takeError());
1268 Next = MaybeNext.get();
1273 llvm::StringRef BlobData;
1275 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1278 consumeError(MaybeKind.takeError());
1281 unsigned Kind = MaybeKind.get();
1288 uint32_t tableOffset;
1289 cxx_method_block::CXXMethodDataLayout::readRecord(Scratch, tableOffset);
1290 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1292 CXXMethodTable.reset(SerializedCXXMethodTable::Create(
1293 base + tableOffset, base +
sizeof(uint32_t), base));
1303 MaybeNext = Cursor.advance();
1306 consumeError(MaybeNext.takeError());
1309 Next = MaybeNext.get();
1323 consumeError(MaybeNext.takeError());
1326 llvm::BitstreamEntry Next = MaybeNext.get();
1327 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1328 if (Next.Kind == llvm::BitstreamEntry::Error)
1331 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1334 if (Cursor.SkipBlock())
1337 MaybeNext = Cursor.advance();
1340 consumeError(MaybeNext.takeError());
1343 Next = MaybeNext.get();
1348 llvm::StringRef BlobData;
1350 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1353 consumeError(MaybeKind.takeError());
1356 unsigned Kind = MaybeKind.get();
1363 uint32_t tableOffset;
1364 field_block::FieldDataLayout::readRecord(Scratch, tableOffset);
1365 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1367 FieldTable.reset(SerializedFieldTable::Create(
1368 base + tableOffset, base +
sizeof(uint32_t), base));
1378 MaybeNext = Cursor.advance();
1381 consumeError(MaybeNext.takeError());
1384 Next = MaybeNext.get();
1398 consumeError(MaybeNext.takeError());
1401 llvm::BitstreamEntry Next = MaybeNext.get();
1402 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1403 if (Next.Kind == llvm::BitstreamEntry::Error)
1406 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1409 if (Cursor.SkipBlock())
1412 MaybeNext = Cursor.advance();
1415 consumeError(MaybeNext.takeError());
1418 Next = MaybeNext.get();
1423 llvm::StringRef BlobData;
1425 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1428 consumeError(MaybeKind.takeError());
1431 unsigned Kind = MaybeKind.get();
1435 if (ObjCSelectorTable)
1438 uint32_t tableOffset;
1439 objc_selector_block::ObjCSelectorDataLayout::readRecord(Scratch,
1441 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1443 ObjCSelectorTable.reset(SerializedObjCSelectorTable::Create(
1444 base + tableOffset, base +
sizeof(uint32_t), base));
1454 MaybeNext = Cursor.advance();
1457 consumeError(MaybeNext.takeError());
1460 Next = MaybeNext.get();
1474 consumeError(MaybeNext.takeError());
1477 llvm::BitstreamEntry Next = MaybeNext.get();
1478 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1479 if (Next.Kind == llvm::BitstreamEntry::Error)
1482 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1485 if (Cursor.SkipBlock())
1488 MaybeNext = Cursor.advance();
1491 consumeError(MaybeNext.takeError());
1494 Next = MaybeNext.get();
1499 llvm::StringRef BlobData;
1501 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1504 consumeError(MaybeKind.takeError());
1507 unsigned Kind = MaybeKind.get();
1511 if (GlobalVariableTable)
1514 uint32_t tableOffset;
1515 global_variable_block::GlobalVariableDataLayout::readRecord(Scratch,
1517 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1519 GlobalVariableTable.reset(SerializedGlobalVariableTable::Create(
1520 base + tableOffset, base +
sizeof(uint32_t), base));
1530 MaybeNext = Cursor.advance();
1533 consumeError(MaybeNext.takeError());
1536 Next = MaybeNext.get();
1550 consumeError(MaybeNext.takeError());
1553 llvm::BitstreamEntry Next = MaybeNext.get();
1554 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1555 if (Next.Kind == llvm::BitstreamEntry::Error)
1558 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1561 if (Cursor.SkipBlock())
1564 MaybeNext = Cursor.advance();
1567 consumeError(MaybeNext.takeError());
1570 Next = MaybeNext.get();
1575 llvm::StringRef BlobData;
1577 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1580 consumeError(MaybeKind.takeError());
1583 unsigned Kind = MaybeKind.get();
1587 if (GlobalFunctionTable)
1590 uint32_t tableOffset;
1591 global_function_block::GlobalFunctionDataLayout::readRecord(Scratch,
1593 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1595 GlobalFunctionTable.reset(SerializedGlobalFunctionTable::Create(
1596 base + tableOffset, base +
sizeof(uint32_t), base));
1606 MaybeNext = Cursor.advance();
1609 consumeError(MaybeNext.takeError());
1612 Next = MaybeNext.get();
1626 consumeError(MaybeNext.takeError());
1629 llvm::BitstreamEntry Next = MaybeNext.get();
1630 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1631 if (Next.Kind == llvm::BitstreamEntry::Error)
1634 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1637 if (Cursor.SkipBlock())
1640 MaybeNext = Cursor.advance();
1643 consumeError(MaybeNext.takeError());
1646 Next = MaybeNext.get();
1651 llvm::StringRef BlobData;
1653 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1656 consumeError(MaybeKind.takeError());
1659 unsigned Kind = MaybeKind.get();
1663 if (EnumConstantTable)
1666 uint32_t tableOffset;
1667 enum_constant_block::EnumConstantDataLayout::readRecord(Scratch,
1669 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1671 EnumConstantTable.reset(SerializedEnumConstantTable::Create(
1672 base + tableOffset, base +
sizeof(uint32_t), base));
1682 MaybeNext = Cursor.advance();
1685 consumeError(MaybeNext.takeError());
1688 Next = MaybeNext.get();
1702 consumeError(MaybeNext.takeError());
1705 llvm::BitstreamEntry Next = MaybeNext.get();
1706 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1707 if (Next.Kind == llvm::BitstreamEntry::Error)
1710 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1713 if (Cursor.SkipBlock())
1716 MaybeNext = Cursor.advance();
1719 consumeError(MaybeNext.takeError());
1722 Next = MaybeNext.get();
1727 llvm::StringRef BlobData;
1729 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1732 consumeError(MaybeKind.takeError());
1735 unsigned Kind = MaybeKind.get();
1742 uint32_t tableOffset;
1743 tag_block::TagDataLayout::readRecord(Scratch, tableOffset);
1744 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1746 TagTable.reset(SerializedTagTable::Create(base + tableOffset,
1747 base +
sizeof(uint32_t), base));
1757 MaybeNext = Cursor.advance();
1760 consumeError(MaybeNext.takeError());
1763 Next = MaybeNext.get();
1777 consumeError(MaybeNext.takeError());
1780 llvm::BitstreamEntry Next = MaybeNext.get();
1781 while (Next.Kind != llvm::BitstreamEntry::EndBlock) {
1782 if (Next.Kind == llvm::BitstreamEntry::Error)
1785 if (Next.Kind == llvm::BitstreamEntry::SubBlock) {
1788 if (Cursor.SkipBlock())
1791 MaybeNext = Cursor.advance();
1794 consumeError(MaybeNext.takeError());
1797 Next = MaybeNext.get();
1802 llvm::StringRef BlobData;
1804 Cursor.readRecord(Next.ID, Scratch, &BlobData);
1807 consumeError(MaybeKind.takeError());
1810 unsigned Kind = MaybeKind.get();
1817 uint32_t tableOffset;
1818 typedef_block::TypedefDataLayout::readRecord(Scratch, tableOffset);
1819 auto base =
reinterpret_cast<const uint8_t *
>(BlobData.data());
1821 TypedefTable.reset(SerializedTypedefTable::Create(
1822 base + tableOffset, base +
sizeof(uint32_t), base));
1832 MaybeNext = Cursor.advance();
1835 consumeError(MaybeNext.takeError());
1838 Next = MaybeNext.get();
1844APINotesReader::APINotesReader(llvm::MemoryBuffer *InputBuffer,
1845 llvm::VersionTuple SwiftVersion,
bool &Failed)
1856 if (Cursor.AtEndOfStream()) {
1862 if (maybeRead.get() !=
byte) {
1868 consumeError(maybeRead.takeError());
1875 bool HasValidControlBlock =
false;
1877 while (!
Cursor.AtEndOfStream()) {
1879 if (!MaybeTopLevelEntry) {
1881 consumeError(MaybeTopLevelEntry.takeError());
1885 llvm::BitstreamEntry TopLevelEntry = MaybeTopLevelEntry.get();
1887 if (TopLevelEntry.Kind != llvm::BitstreamEntry::SubBlock)
1890 switch (TopLevelEntry.ID) {
1891 case llvm::bitc::BLOCKINFO_BLOCK_ID:
1892 if (!
Cursor.ReadBlockInfoBlock()) {
1900 if (HasValidControlBlock ||
1901 Implementation->readControlBlock(Cursor, Scratch)) {
1906 HasValidControlBlock =
true;
1910 if (!HasValidControlBlock ||
1911 Implementation->readIdentifierBlock(Cursor, Scratch)) {
1918 if (!HasValidControlBlock ||
1919 Implementation->readContextBlock(Cursor, Scratch)) {
1927 if (!HasValidControlBlock ||
1928 Implementation->readObjCPropertyBlock(Cursor, Scratch)) {
1935 if (!HasValidControlBlock ||
1936 Implementation->readObjCMethodBlock(Cursor, Scratch)) {
1943 if (!HasValidControlBlock ||
1944 Implementation->readCXXMethodBlock(Cursor, Scratch)) {
1951 if (!HasValidControlBlock ||
1952 Implementation->readFieldBlock(Cursor, Scratch)) {
1959 if (!HasValidControlBlock ||
1960 Implementation->readObjCSelectorBlock(Cursor, Scratch)) {
1967 if (!HasValidControlBlock ||
1968 Implementation->readGlobalVariableBlock(Cursor, Scratch)) {
1975 if (!HasValidControlBlock ||
1976 Implementation->readGlobalFunctionBlock(Cursor, Scratch)) {
1983 if (!HasValidControlBlock ||
1984 Implementation->readEnumConstantBlock(Cursor, Scratch)) {
1991 if (!HasValidControlBlock ||
1992 Implementation->readTagBlock(Cursor, Scratch)) {
1999 if (!HasValidControlBlock ||
2000 Implementation->readTypedefBlock(Cursor, Scratch)) {
2009 if (
Cursor.SkipBlock()) {
2017 if (!
Cursor.AtEndOfStream()) {
2025std::unique_ptr<APINotesReader>
2027 llvm::VersionTuple SwiftVersion) {
2028 bool Failed =
false;
2029 std::unique_ptr<APINotesReader> Reader(
2030 new APINotesReader(InputBuffer.release(), SwiftVersion, Failed));
2037template <
typename T>
2039 llvm::VersionTuple Version,
2041 : Results(
std::move(R)) {
2043 assert(!Results.empty());
2044 assert(std::is_sorted(
2045 Results.begin(), Results.end(),
2046 [](
const std::pair<llvm::VersionTuple, T> &left,
2047 const std::pair<llvm::VersionTuple, T> &right) ->
bool {
2052 assert((&left == &right || left.first != right.first) &&
2053 "two entries for the same version");
2054 return left.first < right.first;
2057 Selected = std::nullopt;
2058 for (
unsigned i = 0, n = Results.size(); i != n; ++i) {
2059 if (!Version.empty() && Results[i].first >= Version) {
2071 if (!Selected && Results[0].first.empty())
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;
2111 -> std::optional<ContextID> {
2113 return std::nullopt;
2117 return std::nullopt;
2124 return std::nullopt;
2132 return std::nullopt;
2136 return std::nullopt;
2140 return std::nullopt;
2149 return std::nullopt;
2153 return std::nullopt;
2156 std::make_tuple(CtxID.Value, *PropertyID, (
char)IsInstance));
2158 return std::nullopt;
2164 bool IsInstanceMethod)
2167 return std::nullopt;
2171 return std::nullopt;
2174 ObjCMethodTableInfo::internal_key_type{CtxID.Value, *SelID,
2177 return std::nullopt;
2185 return std::nullopt;
2189 return std::nullopt;
2194 return std::nullopt;
2202 return std::nullopt;
2206 return std::nullopt;
2211 return std::nullopt;
2217 std::optional<Context> Ctx)
2220 return std::nullopt;
2224 return std::nullopt;
2230 return std::nullopt;
2236 std::optional<Context> Ctx)
2239 return std::nullopt;
2243 return std::nullopt;
2249 return std::nullopt;
2257 return std::nullopt;
2261 return std::nullopt;
2265 return std::nullopt;
2271 std::optional<Context> ParentCtx)
2272 -> std::optional<ContextID> {
2274 return std::nullopt;
2278 return std::nullopt;
2283 return std::nullopt;
2291 return std::nullopt;
2295 return std::nullopt;
2301 return std::nullopt;
2307 std::optional<Context> Ctx)
2310 return std::nullopt;
2314 return std::nullopt;
2320 return std::nullopt;
2326 llvm::StringRef Name, std::optional<ContextID> ParentNamespaceID)
2327 -> std::optional<ContextID> {
2329 return std::nullopt;
2333 return std::nullopt;
2335 uint32_t RawParentNamespaceID =
2336 ParentNamespaceID ? ParentNamespaceID->Value : -1;
2340 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
RetainCountConventionKind
const uint8_t kSwiftConforms
llvm::PointerEmbeddedInt< unsigned, 31 > IdentifierID
SwiftNewTypeKind
The kind of a swift_wrapper/swift_newtype.
EnumExtensibilityKind
The payload for an enum_extensibility attribute.
const uint8_t kSwiftDoesNotConform
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