[clang] [APINotes] Support fields of C/C++ structs (PR #104088)
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 14 10:53:26 PDT 2024
================
@@ -858,6 +867,62 @@ void APINotesWriter::Implementation::writeCXXMethodBlock(
}
}
+namespace {
+/// Used to serialize the on-disk C field table.
+class FieldTableInfo
+ : public VersionedTableInfo<FieldTableInfo, SingleDeclTableKey, FieldInfo> {
+public:
+ unsigned getKeyLength(key_type_ref) {
+ return sizeof(uint32_t) + sizeof(uint32_t);
+ }
+
+ void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) {
+ llvm::support::endian::Writer writer(OS, llvm::endianness::little);
+ writer.write<uint32_t>(Key.parentContextID);
+ writer.write<uint32_t>(Key.nameID);
+ }
+
+ hash_value_type ComputeHash(key_type_ref key) {
+ return static_cast<size_t>(key.hashValue());
+ }
+
+ unsigned getUnversionedInfoSize(const FieldInfo &FI) {
+ return getVariableInfoSize(FI);
+ }
+
+ void emitUnversionedInfo(raw_ostream &OS, const FieldInfo &FI) {
+ emitVariableInfo(OS, FI);
+ }
+};
+} // namespace
+
+void APINotesWriter::Implementation::writeFieldBlock(
+ llvm::BitstreamWriter &Stream) {
+ llvm::BCBlockRAII Scope(Stream, FIELD_BLOCK_ID, 3);
+
+ if (Fields.empty())
+ return;
+
+ {
+ llvm::SmallString<4096> HashTableBlob;
+ uint32_t Offset;
+ {
+ llvm::OnDiskChainedHashTableGenerator<FieldTableInfo> Generator;
+ for (auto &MD : Fields)
----------------
compnerd wrote:
`FD` would be a better initialism
https://github.com/llvm/llvm-project/pull/104088
More information about the cfe-commits
mailing list