@@ -176,8 +176,9 @@ class IdentifierTableInfo {
176176 }
177177};
178178
179- // / Used to deserialize the on-disk Objective-C class table.
180- class ObjCContextIDTableInfo {
179+ // / Used to deserialize the on-disk table of Objective-C classes and C++
180+ // / namespaces.
181+ class ContextIDTableInfo {
181182public:
182183 using internal_key_type = ContextTableKey;
183184 using external_key_type = internal_key_type;
@@ -221,9 +222,8 @@ class ObjCContextIDTableInfo {
221222};
222223
223224// / Used to deserialize the on-disk Objective-C property table.
224- class ObjCContextInfoTableInfo
225- : public VersionedTableInfo<ObjCContextInfoTableInfo, unsigned ,
226- ObjCContextInfo> {
225+ class ContextInfoTableInfo
226+ : public VersionedTableInfo<ContextInfoTableInfo, unsigned , ContextInfo> {
227227public:
228228 static internal_key_type ReadKey (const uint8_t *Data, unsigned Length) {
229229 return endian::readNext<uint32_t , llvm::endianness::little>(Data);
@@ -233,9 +233,9 @@ class ObjCContextInfoTableInfo
233233 return static_cast <size_t >(llvm::hash_value (Key));
234234 }
235235
236- static ObjCContextInfo readUnversioned (internal_key_type Key,
237- const uint8_t *&Data) {
238- ObjCContextInfo Info;
236+ static ContextInfo readUnversioned (internal_key_type Key,
237+ const uint8_t *&Data) {
238+ ContextInfo Info;
239239 ReadCommonTypeInfo (Data, Info);
240240 uint8_t Payload = *Data++;
241241
@@ -614,17 +614,17 @@ class APINotesReader::Implementation {
614614 // / The identifier table.
615615 std::unique_ptr<SerializedIdentifierTable> IdentifierTable;
616616
617- using SerializedObjCContextIDTable =
618- llvm::OnDiskIterableChainedHashTable<ObjCContextIDTableInfo >;
617+ using SerializedContextIDTable =
618+ llvm::OnDiskIterableChainedHashTable<ContextIDTableInfo >;
619619
620- // / The Objective-C context ID table.
621- std::unique_ptr<SerializedObjCContextIDTable> ObjCContextIDTable ;
620+ // / The Objective-C / C++ context ID table.
621+ std::unique_ptr<SerializedContextIDTable> ContextIDTable ;
622622
623- using SerializedObjCContextInfoTable =
624- llvm::OnDiskIterableChainedHashTable<ObjCContextInfoTableInfo >;
623+ using SerializedContextInfoTable =
624+ llvm::OnDiskIterableChainedHashTable<ContextInfoTableInfo >;
625625
626626 // / The Objective-C context info table.
627- std::unique_ptr<SerializedObjCContextInfoTable> ObjCContextInfoTable ;
627+ std::unique_ptr<SerializedContextInfoTable> ContextInfoTable ;
628628
629629 using SerializedObjCPropertyTable =
630630 llvm::OnDiskIterableChainedHashTable<ObjCPropertyTableInfo>;
@@ -685,8 +685,8 @@ class APINotesReader::Implementation {
685685 llvm::SmallVectorImpl<uint64_t > &Scratch);
686686 bool readIdentifierBlock (llvm::BitstreamCursor &Cursor,
687687 llvm::SmallVectorImpl<uint64_t > &Scratch);
688- bool readObjCContextBlock (llvm::BitstreamCursor &Cursor,
689- llvm::SmallVectorImpl<uint64_t > &Scratch);
688+ bool readContextBlock (llvm::BitstreamCursor &Cursor,
689+ llvm::SmallVectorImpl<uint64_t > &Scratch);
690690 bool readObjCPropertyBlock (llvm::BitstreamCursor &Cursor,
691691 llvm::SmallVectorImpl<uint64_t > &Scratch);
692692 bool readObjCMethodBlock (llvm::BitstreamCursor &Cursor,
@@ -906,7 +906,7 @@ bool APINotesReader::Implementation::readIdentifierBlock(
906906 return false ;
907907}
908908
909- bool APINotesReader::Implementation::readObjCContextBlock (
909+ bool APINotesReader::Implementation::readContextBlock (
910910 llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl<uint64_t > &Scratch) {
911911 if (Cursor.EnterSubBlock (OBJC_CONTEXT_BLOCK_ID))
912912 return true ;
@@ -950,31 +950,30 @@ bool APINotesReader::Implementation::readObjCContextBlock(
950950 }
951951 unsigned Kind = MaybeKind.get ();
952952 switch (Kind) {
953- case objc_context_block::OBJC_CONTEXT_ID_DATA : {
954- // Already saw Objective-C context ID table.
955- if (ObjCContextIDTable )
953+ case context_block::CONTEXT_ID_DATA : {
954+ // Already saw Objective-C / C++ context ID table.
955+ if (ContextIDTable )
956956 return true ;
957957
958958 uint32_t tableOffset;
959- objc_context_block::ObjCContextIDLayout ::readRecord (Scratch, tableOffset);
959+ context_block::ContextIDLayout ::readRecord (Scratch, tableOffset);
960960 auto base = reinterpret_cast <const uint8_t *>(BlobData.data ());
961961
962- ObjCContextIDTable .reset (SerializedObjCContextIDTable ::Create (
962+ ContextIDTable .reset (SerializedContextIDTable ::Create (
963963 base + tableOffset, base + sizeof (uint32_t ), base));
964964 break ;
965965 }
966966
967- case objc_context_block::OBJC_CONTEXT_INFO_DATA : {
968- // Already saw Objective-C context info table.
969- if (ObjCContextInfoTable )
967+ case context_block::CONTEXT_INFO_DATA : {
968+ // Already saw Objective-C / C++ context info table.
969+ if (ContextInfoTable )
970970 return true ;
971971
972972 uint32_t tableOffset;
973- objc_context_block::ObjCContextInfoLayout::readRecord (Scratch,
974- tableOffset);
973+ context_block::ContextInfoLayout::readRecord (Scratch, tableOffset);
975974 auto base = reinterpret_cast <const uint8_t *>(BlobData.data ());
976975
977- ObjCContextInfoTable .reset (SerializedObjCContextInfoTable ::Create (
976+ ContextInfoTable .reset (SerializedContextInfoTable ::Create (
978977 base + tableOffset, base + sizeof (uint32_t ), base));
979978 break ;
980979 }
@@ -1678,7 +1677,7 @@ APINotesReader::APINotesReader(llvm::MemoryBuffer *InputBuffer,
16781677
16791678 case OBJC_CONTEXT_BLOCK_ID:
16801679 if (!HasValidControlBlock ||
1681- Implementation->readObjCContextBlock (Cursor, Scratch)) {
1680+ Implementation->readContextBlock (Cursor, Scratch)) {
16821681 Failed = true ;
16831682 return ;
16841683 }
@@ -1815,7 +1814,7 @@ APINotesReader::VersionedInfo<T>::VersionedInfo(
18151814
18161815auto APINotesReader::lookupObjCClassID (llvm::StringRef Name)
18171816 -> std::optional<ContextID> {
1818- if (!Implementation->ObjCContextIDTable )
1817+ if (!Implementation->ContextIDTable )
18191818 return std::nullopt ;
18201819
18211820 std::optional<IdentifierID> ClassID = Implementation->getIdentifier (Name);
@@ -1824,33 +1823,33 @@ auto APINotesReader::lookupObjCClassID(llvm::StringRef Name)
18241823
18251824 // ObjC classes can't be declared in C++ namespaces, so use -1 as the global
18261825 // context.
1827- auto KnownID = Implementation->ObjCContextIDTable ->find (
1826+ auto KnownID = Implementation->ContextIDTable ->find (
18281827 ContextTableKey (-1 , (uint8_t )ContextKind::ObjCClass, *ClassID));
1829- if (KnownID == Implementation->ObjCContextIDTable ->end ())
1828+ if (KnownID == Implementation->ContextIDTable ->end ())
18301829 return std::nullopt ;
18311830
18321831 return ContextID (*KnownID);
18331832}
18341833
18351834auto APINotesReader::lookupObjCClassInfo (llvm::StringRef Name)
1836- -> VersionedInfo<ObjCContextInfo > {
1837- if (!Implementation->ObjCContextInfoTable )
1835+ -> VersionedInfo<ContextInfo > {
1836+ if (!Implementation->ContextInfoTable )
18381837 return std::nullopt ;
18391838
18401839 std::optional<ContextID> CtxID = lookupObjCClassID (Name);
18411840 if (!CtxID)
18421841 return std::nullopt ;
18431842
1844- auto KnownInfo = Implementation->ObjCContextInfoTable ->find (CtxID->Value );
1845- if (KnownInfo == Implementation->ObjCContextInfoTable ->end ())
1843+ auto KnownInfo = Implementation->ContextInfoTable ->find (CtxID->Value );
1844+ if (KnownInfo == Implementation->ContextInfoTable ->end ())
18461845 return std::nullopt ;
18471846
18481847 return {Implementation->SwiftVersion , *KnownInfo};
18491848}
18501849
18511850auto APINotesReader::lookupObjCProtocolID (llvm::StringRef Name)
18521851 -> std::optional<ContextID> {
1853- if (!Implementation->ObjCContextIDTable )
1852+ if (!Implementation->ContextIDTable )
18541853 return std::nullopt ;
18551854
18561855 std::optional<IdentifierID> classID = Implementation->getIdentifier (Name);
@@ -1859,25 +1858,25 @@ auto APINotesReader::lookupObjCProtocolID(llvm::StringRef Name)
18591858
18601859 // ObjC classes can't be declared in C++ namespaces, so use -1 as the global
18611860 // context.
1862- auto KnownID = Implementation->ObjCContextIDTable ->find (
1861+ auto KnownID = Implementation->ContextIDTable ->find (
18631862 ContextTableKey (-1 , (uint8_t )ContextKind::ObjCProtocol, *classID));
1864- if (KnownID == Implementation->ObjCContextIDTable ->end ())
1863+ if (KnownID == Implementation->ContextIDTable ->end ())
18651864 return std::nullopt ;
18661865
18671866 return ContextID (*KnownID);
18681867}
18691868
18701869auto APINotesReader::lookupObjCProtocolInfo (llvm::StringRef Name)
1871- -> VersionedInfo<ObjCContextInfo > {
1872- if (!Implementation->ObjCContextInfoTable )
1870+ -> VersionedInfo<ContextInfo > {
1871+ if (!Implementation->ContextInfoTable )
18731872 return std::nullopt ;
18741873
18751874 std::optional<ContextID> CtxID = lookupObjCProtocolID (Name);
18761875 if (!CtxID)
18771876 return std::nullopt ;
18781877
1879- auto KnownInfo = Implementation->ObjCContextInfoTable ->find (CtxID->Value );
1880- if (KnownInfo == Implementation->ObjCContextInfoTable ->end ())
1878+ auto KnownInfo = Implementation->ContextInfoTable ->find (CtxID->Value );
1879+ if (KnownInfo == Implementation->ContextInfoTable ->end ())
18811880 return std::nullopt ;
18821881
18831882 return {Implementation->SwiftVersion , *KnownInfo};
@@ -2014,7 +2013,7 @@ auto APINotesReader::lookupTypedef(llvm::StringRef Name,
20142013auto APINotesReader::lookupNamespaceID (
20152014 llvm::StringRef Name, std::optional<ContextID> ParentNamespaceID)
20162015 -> std::optional<ContextID> {
2017- if (!Implementation->ObjCContextIDTable )
2016+ if (!Implementation->ContextIDTable )
20182017 return std::nullopt ;
20192018
20202019 std::optional<IdentifierID> NamespaceID = Implementation->getIdentifier (Name);
@@ -2023,9 +2022,9 @@ auto APINotesReader::lookupNamespaceID(
20232022
20242023 uint32_t RawParentNamespaceID =
20252024 ParentNamespaceID ? ParentNamespaceID->Value : -1 ;
2026- auto KnownID = Implementation->ObjCContextIDTable ->find (
2025+ auto KnownID = Implementation->ContextIDTable ->find (
20272026 {RawParentNamespaceID, (uint8_t )ContextKind::Namespace, *NamespaceID});
2028- if (KnownID == Implementation->ObjCContextIDTable ->end ())
2027+ if (KnownID == Implementation->ContextIDTable ->end ())
20292028 return std::nullopt ;
20302029
20312030 return ContextID (*KnownID);
0 commit comments