@@ -176,8 +176,9 @@ class IdentifierTableInfo {
176
176
}
177
177
};
178
178
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 {
181
182
public:
182
183
using internal_key_type = ContextTableKey;
183
184
using external_key_type = internal_key_type;
@@ -221,9 +222,8 @@ class ObjCContextIDTableInfo {
221
222
};
222
223
223
224
// / 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> {
227
227
public:
228
228
static internal_key_type ReadKey (const uint8_t *Data, unsigned Length) {
229
229
return endian::readNext<uint32_t , llvm::endianness::little>(Data);
@@ -233,9 +233,9 @@ class ObjCContextInfoTableInfo
233
233
return static_cast <size_t >(llvm::hash_value (Key));
234
234
}
235
235
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;
239
239
ReadCommonTypeInfo (Data, Info);
240
240
uint8_t Payload = *Data++;
241
241
@@ -614,17 +614,17 @@ class APINotesReader::Implementation {
614
614
// / The identifier table.
615
615
std::unique_ptr<SerializedIdentifierTable> IdentifierTable;
616
616
617
- using SerializedObjCContextIDTable =
618
- llvm::OnDiskIterableChainedHashTable<ObjCContextIDTableInfo >;
617
+ using SerializedContextIDTable =
618
+ llvm::OnDiskIterableChainedHashTable<ContextIDTableInfo >;
619
619
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 ;
622
622
623
- using SerializedObjCContextInfoTable =
624
- llvm::OnDiskIterableChainedHashTable<ObjCContextInfoTableInfo >;
623
+ using SerializedContextInfoTable =
624
+ llvm::OnDiskIterableChainedHashTable<ContextInfoTableInfo >;
625
625
626
626
// / The Objective-C context info table.
627
- std::unique_ptr<SerializedObjCContextInfoTable> ObjCContextInfoTable ;
627
+ std::unique_ptr<SerializedContextInfoTable> ContextInfoTable ;
628
628
629
629
using SerializedObjCPropertyTable =
630
630
llvm::OnDiskIterableChainedHashTable<ObjCPropertyTableInfo>;
@@ -685,8 +685,8 @@ class APINotesReader::Implementation {
685
685
llvm::SmallVectorImpl<uint64_t > &Scratch);
686
686
bool readIdentifierBlock (llvm::BitstreamCursor &Cursor,
687
687
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);
690
690
bool readObjCPropertyBlock (llvm::BitstreamCursor &Cursor,
691
691
llvm::SmallVectorImpl<uint64_t > &Scratch);
692
692
bool readObjCMethodBlock (llvm::BitstreamCursor &Cursor,
@@ -906,7 +906,7 @@ bool APINotesReader::Implementation::readIdentifierBlock(
906
906
return false ;
907
907
}
908
908
909
- bool APINotesReader::Implementation::readObjCContextBlock (
909
+ bool APINotesReader::Implementation::readContextBlock (
910
910
llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl<uint64_t > &Scratch) {
911
911
if (Cursor.EnterSubBlock (OBJC_CONTEXT_BLOCK_ID))
912
912
return true ;
@@ -950,31 +950,30 @@ bool APINotesReader::Implementation::readObjCContextBlock(
950
950
}
951
951
unsigned Kind = MaybeKind.get ();
952
952
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 )
956
956
return true ;
957
957
958
958
uint32_t tableOffset;
959
- objc_context_block::ObjCContextIDLayout ::readRecord (Scratch, tableOffset);
959
+ context_block::ContextIDLayout ::readRecord (Scratch, tableOffset);
960
960
auto base = reinterpret_cast <const uint8_t *>(BlobData.data ());
961
961
962
- ObjCContextIDTable .reset (SerializedObjCContextIDTable ::Create (
962
+ ContextIDTable .reset (SerializedContextIDTable ::Create (
963
963
base + tableOffset, base + sizeof (uint32_t ), base));
964
964
break ;
965
965
}
966
966
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 )
970
970
return true ;
971
971
972
972
uint32_t tableOffset;
973
- objc_context_block::ObjCContextInfoLayout::readRecord (Scratch,
974
- tableOffset);
973
+ context_block::ContextInfoLayout::readRecord (Scratch, tableOffset);
975
974
auto base = reinterpret_cast <const uint8_t *>(BlobData.data ());
976
975
977
- ObjCContextInfoTable .reset (SerializedObjCContextInfoTable ::Create (
976
+ ContextInfoTable .reset (SerializedContextInfoTable ::Create (
978
977
base + tableOffset, base + sizeof (uint32_t ), base));
979
978
break ;
980
979
}
@@ -1678,7 +1677,7 @@ APINotesReader::APINotesReader(llvm::MemoryBuffer *InputBuffer,
1678
1677
1679
1678
case OBJC_CONTEXT_BLOCK_ID:
1680
1679
if (!HasValidControlBlock ||
1681
- Implementation->readObjCContextBlock (Cursor, Scratch)) {
1680
+ Implementation->readContextBlock (Cursor, Scratch)) {
1682
1681
Failed = true ;
1683
1682
return ;
1684
1683
}
@@ -1815,7 +1814,7 @@ APINotesReader::VersionedInfo<T>::VersionedInfo(
1815
1814
1816
1815
auto APINotesReader::lookupObjCClassID (llvm::StringRef Name)
1817
1816
-> std::optional<ContextID> {
1818
- if (!Implementation->ObjCContextIDTable )
1817
+ if (!Implementation->ContextIDTable )
1819
1818
return std::nullopt;
1820
1819
1821
1820
std::optional<IdentifierID> ClassID = Implementation->getIdentifier (Name);
@@ -1824,33 +1823,33 @@ auto APINotesReader::lookupObjCClassID(llvm::StringRef Name)
1824
1823
1825
1824
// ObjC classes can't be declared in C++ namespaces, so use -1 as the global
1826
1825
// context.
1827
- auto KnownID = Implementation->ObjCContextIDTable ->find (
1826
+ auto KnownID = Implementation->ContextIDTable ->find (
1828
1827
ContextTableKey (-1 , (uint8_t )ContextKind::ObjCClass, *ClassID));
1829
- if (KnownID == Implementation->ObjCContextIDTable ->end ())
1828
+ if (KnownID == Implementation->ContextIDTable ->end ())
1830
1829
return std::nullopt;
1831
1830
1832
1831
return ContextID (*KnownID);
1833
1832
}
1834
1833
1835
1834
auto APINotesReader::lookupObjCClassInfo (llvm::StringRef Name)
1836
- -> VersionedInfo<ObjCContextInfo > {
1837
- if (!Implementation->ObjCContextInfoTable )
1835
+ -> VersionedInfo<ContextInfo > {
1836
+ if (!Implementation->ContextInfoTable )
1838
1837
return std::nullopt;
1839
1838
1840
1839
std::optional<ContextID> CtxID = lookupObjCClassID (Name);
1841
1840
if (!CtxID)
1842
1841
return std::nullopt;
1843
1842
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 ())
1846
1845
return std::nullopt;
1847
1846
1848
1847
return {Implementation->SwiftVersion , *KnownInfo};
1849
1848
}
1850
1849
1851
1850
auto APINotesReader::lookupObjCProtocolID (llvm::StringRef Name)
1852
1851
-> std::optional<ContextID> {
1853
- if (!Implementation->ObjCContextIDTable )
1852
+ if (!Implementation->ContextIDTable )
1854
1853
return std::nullopt;
1855
1854
1856
1855
std::optional<IdentifierID> classID = Implementation->getIdentifier (Name);
@@ -1859,25 +1858,25 @@ auto APINotesReader::lookupObjCProtocolID(llvm::StringRef Name)
1859
1858
1860
1859
// ObjC classes can't be declared in C++ namespaces, so use -1 as the global
1861
1860
// context.
1862
- auto KnownID = Implementation->ObjCContextIDTable ->find (
1861
+ auto KnownID = Implementation->ContextIDTable ->find (
1863
1862
ContextTableKey (-1 , (uint8_t )ContextKind::ObjCProtocol, *classID));
1864
- if (KnownID == Implementation->ObjCContextIDTable ->end ())
1863
+ if (KnownID == Implementation->ContextIDTable ->end ())
1865
1864
return std::nullopt;
1866
1865
1867
1866
return ContextID (*KnownID);
1868
1867
}
1869
1868
1870
1869
auto APINotesReader::lookupObjCProtocolInfo (llvm::StringRef Name)
1871
- -> VersionedInfo<ObjCContextInfo > {
1872
- if (!Implementation->ObjCContextInfoTable )
1870
+ -> VersionedInfo<ContextInfo > {
1871
+ if (!Implementation->ContextInfoTable )
1873
1872
return std::nullopt;
1874
1873
1875
1874
std::optional<ContextID> CtxID = lookupObjCProtocolID (Name);
1876
1875
if (!CtxID)
1877
1876
return std::nullopt;
1878
1877
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 ())
1881
1880
return std::nullopt;
1882
1881
1883
1882
return {Implementation->SwiftVersion , *KnownInfo};
@@ -2014,7 +2013,7 @@ auto APINotesReader::lookupTypedef(llvm::StringRef Name,
2014
2013
auto APINotesReader::lookupNamespaceID (
2015
2014
llvm::StringRef Name, std::optional<ContextID> ParentNamespaceID)
2016
2015
-> std::optional<ContextID> {
2017
- if (!Implementation->ObjCContextIDTable )
2016
+ if (!Implementation->ContextIDTable )
2018
2017
return std::nullopt;
2019
2018
2020
2019
std::optional<IdentifierID> NamespaceID = Implementation->getIdentifier (Name);
@@ -2023,9 +2022,9 @@ auto APINotesReader::lookupNamespaceID(
2023
2022
2024
2023
uint32_t RawParentNamespaceID =
2025
2024
ParentNamespaceID ? ParentNamespaceID->Value : -1 ;
2026
- auto KnownID = Implementation->ObjCContextIDTable ->find (
2025
+ auto KnownID = Implementation->ContextIDTable ->find (
2027
2026
{RawParentNamespaceID, (uint8_t )ContextKind::Namespace, *NamespaceID});
2028
- if (KnownID == Implementation->ObjCContextIDTable ->end ())
2027
+ if (KnownID == Implementation->ContextIDTable ->end ())
2029
2028
return std::nullopt;
2030
2029
2031
2030
return ContextID (*KnownID);
0 commit comments