@@ -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
@@ -617,17 +617,17 @@ class APINotesReader::Implementation {
617
617
// / The identifier table.
618
618
std::unique_ptr<SerializedIdentifierTable> IdentifierTable;
619
619
620
- using SerializedObjCContextIDTable =
621
- llvm::OnDiskIterableChainedHashTable<ObjCContextIDTableInfo >;
620
+ using SerializedContextIDTable =
621
+ llvm::OnDiskIterableChainedHashTable<ContextIDTableInfo >;
622
622
623
- // / The Objective-C context ID table.
624
- std::unique_ptr<SerializedObjCContextIDTable> ObjCContextIDTable ;
623
+ // / The Objective-C / C++ context ID table.
624
+ std::unique_ptr<SerializedContextIDTable> ContextIDTable ;
625
625
626
- using SerializedObjCContextInfoTable =
627
- llvm::OnDiskIterableChainedHashTable<ObjCContextInfoTableInfo >;
626
+ using SerializedContextInfoTable =
627
+ llvm::OnDiskIterableChainedHashTable<ContextInfoTableInfo >;
628
628
629
629
// / The Objective-C context info table.
630
- std::unique_ptr<SerializedObjCContextInfoTable> ObjCContextInfoTable ;
630
+ std::unique_ptr<SerializedContextInfoTable> ContextInfoTable ;
631
631
632
632
using SerializedObjCPropertyTable =
633
633
llvm::OnDiskIterableChainedHashTable<ObjCPropertyTableInfo>;
@@ -688,8 +688,8 @@ class APINotesReader::Implementation {
688
688
llvm::SmallVectorImpl<uint64_t > &Scratch);
689
689
bool readIdentifierBlock (llvm::BitstreamCursor &Cursor,
690
690
llvm::SmallVectorImpl<uint64_t > &Scratch);
691
- bool readObjCContextBlock (llvm::BitstreamCursor &Cursor,
692
- llvm::SmallVectorImpl<uint64_t > &Scratch);
691
+ bool readContextBlock (llvm::BitstreamCursor &Cursor,
692
+ llvm::SmallVectorImpl<uint64_t > &Scratch);
693
693
bool readObjCPropertyBlock (llvm::BitstreamCursor &Cursor,
694
694
llvm::SmallVectorImpl<uint64_t > &Scratch);
695
695
bool readObjCMethodBlock (llvm::BitstreamCursor &Cursor,
@@ -910,7 +910,7 @@ bool APINotesReader::Implementation::readIdentifierBlock(
910
910
return false ;
911
911
}
912
912
913
- bool APINotesReader::Implementation::readObjCContextBlock (
913
+ bool APINotesReader::Implementation::readContextBlock (
914
914
llvm::BitstreamCursor &Cursor, llvm::SmallVectorImpl<uint64_t > &Scratch) {
915
915
if (Cursor.EnterSubBlock (OBJC_CONTEXT_BLOCK_ID))
916
916
return true ;
@@ -954,31 +954,30 @@ bool APINotesReader::Implementation::readObjCContextBlock(
954
954
}
955
955
unsigned Kind = MaybeKind.get ();
956
956
switch (Kind) {
957
- case objc_context_block::OBJC_CONTEXT_ID_DATA : {
958
- // Already saw Objective-C context ID table.
959
- if (ObjCContextIDTable )
957
+ case context_block::CONTEXT_ID_DATA : {
958
+ // Already saw Objective-C / C++ context ID table.
959
+ if (ContextIDTable )
960
960
return true ;
961
961
962
962
uint32_t tableOffset;
963
- objc_context_block::ObjCContextIDLayout ::readRecord (Scratch, tableOffset);
963
+ context_block::ContextIDLayout ::readRecord (Scratch, tableOffset);
964
964
auto base = reinterpret_cast <const uint8_t *>(BlobData.data ());
965
965
966
- ObjCContextIDTable .reset (SerializedObjCContextIDTable ::Create (
966
+ ContextIDTable .reset (SerializedContextIDTable ::Create (
967
967
base + tableOffset, base + sizeof (uint32_t ), base));
968
968
break ;
969
969
}
970
970
971
- case objc_context_block::OBJC_CONTEXT_INFO_DATA : {
972
- // Already saw Objective-C context info table.
973
- if (ObjCContextInfoTable )
971
+ case context_block::CONTEXT_INFO_DATA : {
972
+ // Already saw Objective-C / C++ context info table.
973
+ if (ContextInfoTable )
974
974
return true ;
975
975
976
976
uint32_t tableOffset;
977
- objc_context_block::ObjCContextInfoLayout::readRecord (Scratch,
978
- tableOffset);
977
+ context_block::ContextInfoLayout::readRecord (Scratch, tableOffset);
979
978
auto base = reinterpret_cast <const uint8_t *>(BlobData.data ());
980
979
981
- ObjCContextInfoTable .reset (SerializedObjCContextInfoTable ::Create (
980
+ ContextInfoTable .reset (SerializedContextInfoTable ::Create (
982
981
base + tableOffset, base + sizeof (uint32_t ), base));
983
982
break ;
984
983
}
@@ -1682,7 +1681,7 @@ APINotesReader::APINotesReader(llvm::MemoryBuffer *InputBuffer,
1682
1681
1683
1682
case OBJC_CONTEXT_BLOCK_ID:
1684
1683
if (!HasValidControlBlock ||
1685
- Implementation->readObjCContextBlock (Cursor, Scratch)) {
1684
+ Implementation->readContextBlock (Cursor, Scratch)) {
1686
1685
Failed = true ;
1687
1686
return ;
1688
1687
}
@@ -1827,7 +1826,7 @@ APINotesReader::VersionedInfo<T>::VersionedInfo(
1827
1826
1828
1827
auto APINotesReader::lookupObjCClassID (llvm::StringRef Name)
1829
1828
-> std::optional<ContextID> {
1830
- if (!Implementation->ObjCContextIDTable )
1829
+ if (!Implementation->ContextIDTable )
1831
1830
return std::nullopt;
1832
1831
1833
1832
std::optional<IdentifierID> ClassID = Implementation->getIdentifier (Name);
@@ -1836,33 +1835,33 @@ auto APINotesReader::lookupObjCClassID(llvm::StringRef Name)
1836
1835
1837
1836
// ObjC classes can't be declared in C++ namespaces, so use -1 as the global
1838
1837
// context.
1839
- auto KnownID = Implementation->ObjCContextIDTable ->find (
1838
+ auto KnownID = Implementation->ContextIDTable ->find (
1840
1839
ContextTableKey (-1 , (uint8_t )ContextKind::ObjCClass, *ClassID));
1841
- if (KnownID == Implementation->ObjCContextIDTable ->end ())
1840
+ if (KnownID == Implementation->ContextIDTable ->end ())
1842
1841
return std::nullopt;
1843
1842
1844
1843
return ContextID (*KnownID);
1845
1844
}
1846
1845
1847
1846
auto APINotesReader::lookupObjCClassInfo (llvm::StringRef Name)
1848
- -> VersionedInfo<ObjCContextInfo > {
1849
- if (!Implementation->ObjCContextInfoTable )
1847
+ -> VersionedInfo<ContextInfo > {
1848
+ if (!Implementation->ContextInfoTable )
1850
1849
return std::nullopt;
1851
1850
1852
1851
std::optional<ContextID> CtxID = lookupObjCClassID (Name);
1853
1852
if (!CtxID)
1854
1853
return std::nullopt;
1855
1854
1856
- auto KnownInfo = Implementation->ObjCContextInfoTable ->find (CtxID->Value );
1857
- if (KnownInfo == Implementation->ObjCContextInfoTable ->end ())
1855
+ auto KnownInfo = Implementation->ContextInfoTable ->find (CtxID->Value );
1856
+ if (KnownInfo == Implementation->ContextInfoTable ->end ())
1858
1857
return std::nullopt;
1859
1858
1860
1859
return {Implementation->SwiftVersion , *KnownInfo};
1861
1860
}
1862
1861
1863
1862
auto APINotesReader::lookupObjCProtocolID (llvm::StringRef Name)
1864
1863
-> std::optional<ContextID> {
1865
- if (!Implementation->ObjCContextIDTable )
1864
+ if (!Implementation->ContextIDTable )
1866
1865
return std::nullopt;
1867
1866
1868
1867
std::optional<IdentifierID> classID = Implementation->getIdentifier (Name);
@@ -1871,25 +1870,25 @@ auto APINotesReader::lookupObjCProtocolID(llvm::StringRef Name)
1871
1870
1872
1871
// ObjC classes can't be declared in C++ namespaces, so use -1 as the global
1873
1872
// context.
1874
- auto KnownID = Implementation->ObjCContextIDTable ->find (
1873
+ auto KnownID = Implementation->ContextIDTable ->find (
1875
1874
ContextTableKey (-1 , (uint8_t )ContextKind::ObjCProtocol, *classID));
1876
- if (KnownID == Implementation->ObjCContextIDTable ->end ())
1875
+ if (KnownID == Implementation->ContextIDTable ->end ())
1877
1876
return std::nullopt;
1878
1877
1879
1878
return ContextID (*KnownID);
1880
1879
}
1881
1880
1882
1881
auto APINotesReader::lookupObjCProtocolInfo (llvm::StringRef Name)
1883
- -> VersionedInfo<ObjCContextInfo > {
1884
- if (!Implementation->ObjCContextInfoTable )
1882
+ -> VersionedInfo<ContextInfo > {
1883
+ if (!Implementation->ContextInfoTable )
1885
1884
return std::nullopt;
1886
1885
1887
1886
std::optional<ContextID> CtxID = lookupObjCProtocolID (Name);
1888
1887
if (!CtxID)
1889
1888
return std::nullopt;
1890
1889
1891
- auto KnownInfo = Implementation->ObjCContextInfoTable ->find (CtxID->Value );
1892
- if (KnownInfo == Implementation->ObjCContextInfoTable ->end ())
1890
+ auto KnownInfo = Implementation->ContextInfoTable ->find (CtxID->Value );
1891
+ if (KnownInfo == Implementation->ContextInfoTable ->end ())
1893
1892
return std::nullopt;
1894
1893
1895
1894
return {Implementation->SwiftVersion , *KnownInfo};
@@ -2026,7 +2025,7 @@ auto APINotesReader::lookupTypedef(llvm::StringRef Name,
2026
2025
auto APINotesReader::lookupNamespaceID (
2027
2026
llvm::StringRef Name, std::optional<ContextID> ParentNamespaceID)
2028
2027
-> std::optional<ContextID> {
2029
- if (!Implementation->ObjCContextIDTable )
2028
+ if (!Implementation->ContextIDTable )
2030
2029
return std::nullopt;
2031
2030
2032
2031
std::optional<IdentifierID> NamespaceID = Implementation->getIdentifier (Name);
@@ -2035,9 +2034,9 @@ auto APINotesReader::lookupNamespaceID(
2035
2034
2036
2035
uint32_t RawParentNamespaceID =
2037
2036
ParentNamespaceID ? ParentNamespaceID->Value : -1 ;
2038
- auto KnownID = Implementation->ObjCContextIDTable ->find (
2037
+ auto KnownID = Implementation->ContextIDTable ->find (
2039
2038
{RawParentNamespaceID, (uint8_t )ContextKind::Namespace, *NamespaceID});
2040
- if (KnownID == Implementation->ObjCContextIDTable ->end ())
2039
+ if (KnownID == Implementation->ContextIDTable ->end ())
2041
2040
return std::nullopt;
2042
2041
2043
2042
return ContextID (*KnownID);
0 commit comments