Lines Matching +full:os +full:- +full:data +full:- +full:offset

1 //===-- APINotesWriter.cpp - API Notes Writer -------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
38 /// Information about contexts (Objective-C classes or protocols or C++
56 /// Information about Objective-C properties.
65 /// Information about Objective-C methods.
127 return Known->second; in getIdentifier()
131 return Known->second; in getIdentifier()
146 return Known->second; in getSelector()
150 return Known->second; in getSelector()
172 void writeToStream(llvm::raw_ostream &OS);
175 void APINotesWriter::Implementation::writeToStream(llvm::raw_ostream &OS) { in writeToStream() argument
201 OS.write(Buffer.data(), Buffer.size()); in writeToStream()
202 OS.flush(); in writeToStream()
219 reinterpret_cast<const unsigned char *>(Name.data())), in emitBlockID()
231 memcpy(Buffer.data() + 1, Name.data(), Name.size()); in emitRecordID()
280 ModuleName.emit(Scratch, this->ModuleName); in writeControlBlock()
284 SourceFile.emit(Scratch, this->SourceFile->getSize(), in writeControlBlock()
285 this->SourceFile->getModificationTime()); in writeControlBlock()
290 /// Used to serialize the on-disk identifier table.
303 EmitKeyDataLength(raw_ostream &OS, key_type_ref Key, data_type_ref) { in EmitKeyDataLength() argument
307 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKeyDataLength()
313 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { OS << Key; } in EmitKey() argument
315 void EmitData(raw_ostream &OS, key_type_ref, data_type_ref Data, unsigned) { in EmitData() argument
316 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitData()
317 writer.write<uint32_t>(Data); in EmitData()
330 uint32_t Offset; in writeIdentifierBlock() local
337 // Make sure that no bucket is at offset 0 in writeIdentifierBlock()
340 Offset = Generator.Emit(BlobStream); in writeIdentifierBlock()
344 IdentifierData.emit(Scratch, Offset, HashTableBlob); in writeIdentifierBlock()
348 /// Used to serialize the on-disk Objective-C context table.
362 std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &OS, key_type_ref, in EmitKeyDataLength() argument
367 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKeyDataLength()
373 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
374 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
380 void EmitData(raw_ostream &OS, key_type_ref, data_type_ref Data, unsigned) { in EmitData() argument
381 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitData()
382 writer.write<uint32_t>(Data); in EmitData()
391 /// on-disk hash tables.
418 void emitVersionTuple(raw_ostream &OS, const VersionTuple &VT) { in emitVersionTuple() argument
419 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitVersionTuple()
446 raw_ostream &OS, llvm::SmallVectorImpl<std::pair<VersionTuple, T>> &VI, in emitVersionedInfo() argument
452 const std::pair<VersionTuple, T> &RHS) -> bool { in emitVersionedInfo()
458 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitVersionedInfo()
461 emitVersionTuple(OS, E.first); in emitVersionedInfo()
462 emitInfo(OS, E.second); in emitVersionedInfo()
466 /// On-disk hash table info key base for handling versioned data.
485 EmitKeyDataLength(raw_ostream &OS, key_type_ref Key, data_type_ref Data) { in EmitKeyDataLength() argument
488 getVersionedInfoSize(Data, [this](const UnversionedDataType &UI) { in EmitKeyDataLength()
492 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKeyDataLength()
498 void EmitData(raw_ostream &OS, key_type_ref, data_type_ref Data, unsigned) { in EmitData() argument
500 OS, Data, [this](llvm::raw_ostream &OS, const UnversionedDataType &UI) { in EmitData() argument
501 asDerived().emitUnversionedInfo(OS, UI); in EmitData()
507 void emitCommonEntityInfo(raw_ostream &OS, const CommonEntityInfo &CEI) { in emitCommonEntityInfo() argument
508 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitCommonEntityInfo()
524 OS.write(CEI.UnavailableMsg.c_str(), CEI.UnavailableMsg.size()); in emitCommonEntityInfo()
527 OS.write(CEI.SwiftName.c_str(), CEI.SwiftName.size()); in emitCommonEntityInfo()
531 /// on-disk hash tables.
537 // in on-disk hash tables.
539 return 2 + (CTI.getSwiftBridge() ? CTI.getSwiftBridge()->size() : 0) + 2 + in getCommonTypeInfoSize()
540 (CTI.getNSErrorDomain() ? CTI.getNSErrorDomain()->size() : 0) + in getCommonTypeInfoSize()
545 void emitCommonTypeInfo(raw_ostream &OS, const CommonTypeInfo &CTI) { in emitCommonTypeInfo() argument
546 emitCommonEntityInfo(OS, CTI); in emitCommonTypeInfo()
548 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitCommonTypeInfo()
550 writer.write<uint16_t>(swiftBridge->size() + 1); in emitCommonTypeInfo()
551 OS.write(swiftBridge->c_str(), swiftBridge->size()); in emitCommonTypeInfo()
556 writer.write<uint16_t>(nsErrorDomain->size() + 1); in emitCommonTypeInfo()
557 OS.write(nsErrorDomain->c_str(), CTI.getNSErrorDomain()->size()); in emitCommonTypeInfo()
563 /// Used to serialize the on-disk Objective-C property table.
569 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
570 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
582 void emitUnversionedInfo(raw_ostream &OS, const ContextInfo &OCI) { in emitUnversionedInfo() argument
583 emitCommonTypeInfo(OS, OCI); in emitUnversionedInfo()
596 OS << payload; in emitUnversionedInfo()
610 uint32_t Offset; in writeContextBlock() local
617 // Make sure that no bucket is at offset 0 in writeContextBlock()
620 Offset = Generator.Emit(BlobStream); in writeContextBlock()
624 ContextID.emit(Scratch, Offset, HashTableBlob); in writeContextBlock()
629 uint32_t Offset; in writeContextBlock() local
636 // Make sure that no bucket is at offset 0 in writeContextBlock()
639 Offset = Generator.Emit(BlobStream); in writeContextBlock()
643 ContextInfo.emit(Scratch, Offset, HashTableBlob); in writeContextBlock()
649 /// on-disk hash tables.
655 void emitVariableInfo(raw_ostream &OS, const VariableInfo &VI) { in emitVariableInfo() argument
656 emitCommonEntityInfo(OS, VI); in emitVariableInfo()
666 OS.write(reinterpret_cast<const char *>(bytes), 2); in emitVariableInfo()
668 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitVariableInfo()
670 OS.write(VI.getType().data(), VI.getType().size()); in emitVariableInfo()
673 /// Used to serialize the on-disk Objective-C property table.
683 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
684 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
698 void emitUnversionedInfo(raw_ostream &OS, const ObjCPropertyInfo &OPI) { in emitUnversionedInfo() argument
699 emitVariableInfo(OS, OPI); in emitUnversionedInfo()
706 OS << flags; in emitUnversionedInfo()
720 uint32_t Offset; in writeObjCPropertyBlock() local
727 // Make sure that no bucket is at offset 0 in writeObjCPropertyBlock()
730 Offset = Generator.Emit(BlobStream); in writeObjCPropertyBlock()
734 ObjCPropertyData.emit(Scratch, Offset, HashTableBlob); in writeObjCPropertyBlock()
742 /// Used to serialize the on-disk Objective-C method table.
752 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
753 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
767 void emitUnversionedInfo(raw_ostream &OS, const ObjCMethodInfo &OMI) { in emitUnversionedInfo() argument
769 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitUnversionedInfo()
774 emitFunctionInfo(OS, OMI); in emitUnversionedInfo()
778 /// Used to serialize the on-disk C++ method table.
787 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
788 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
801 void emitUnversionedInfo(raw_ostream &OS, const CXXMethodInfo &OMI) { in emitUnversionedInfo() argument
802 emitFunctionInfo(OS, OMI); in emitUnversionedInfo()
816 uint32_t Offset; in writeObjCMethodBlock() local
823 // Make sure that no bucket is at offset 0 in writeObjCMethodBlock()
826 Offset = Generator.Emit(BlobStream); in writeObjCMethodBlock()
830 ObjCMethodData.emit(Scratch, Offset, HashTableBlob); in writeObjCMethodBlock()
843 uint32_t Offset; in writeCXXMethodBlock() local
850 // Make sure that no bucket is at offset 0 in writeCXXMethodBlock()
853 Offset = Generator.Emit(BlobStream); in writeCXXMethodBlock()
857 CXXMethodData.emit(Scratch, Offset, HashTableBlob); in writeCXXMethodBlock()
862 /// Used to serialize the on-disk Objective-C selector table.
877 EmitKeyDataLength(raw_ostream &OS, key_type_ref Key, data_type_ref) { in EmitKeyDataLength() argument
882 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKeyDataLength()
888 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
889 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
895 void EmitData(raw_ostream &OS, key_type_ref, data_type_ref Data, unsigned) { in EmitData() argument
896 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitData()
897 writer.write<uint32_t>(Data); in EmitData()
911 uint32_t Offset; in writeObjCSelectorBlock() local
918 // Make sure that no bucket is at offset 0 in writeObjCSelectorBlock()
921 Offset = Generator.Emit(BlobStream); in writeObjCSelectorBlock()
925 ObjCSelectorData.emit(Scratch, Offset, HashTableBlob); in writeObjCSelectorBlock()
930 /// Used to serialize the on-disk global variable table.
939 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
940 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
953 void emitUnversionedInfo(raw_ostream &OS, const GlobalVariableInfo &GVI) { in emitUnversionedInfo() argument
954 emitVariableInfo(OS, GVI); in emitUnversionedInfo()
968 uint32_t Offset; in writeGlobalVariableBlock() local
975 // Make sure that no bucket is at offset 0 in writeGlobalVariableBlock()
978 Offset = Generator.Emit(BlobStream); in writeGlobalVariableBlock()
982 GlobalVariableData.emit(Scratch, Offset, HashTableBlob); in writeGlobalVariableBlock()
991 void emitParamInfo(raw_ostream &OS, const ParamInfo &PI) { in emitParamInfo() argument
992 emitVariableInfo(OS, PI); in emitParamInfo()
1004 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitParamInfo()
1008 /// Retrieve the serialized size of the given FunctionInfo, for use in on-disk
1020 void emitFunctionInfo(raw_ostream &OS, const FunctionInfo &FI) { in emitFunctionInfo() argument
1021 emitCommonEntityInfo(OS, FI); in emitFunctionInfo()
1029 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitFunctionInfo()
1037 emitParamInfo(OS, PI); in emitFunctionInfo()
1040 writer.write(ArrayRef<char>{FI.ResultType.data(), FI.ResultType.size()}); in emitFunctionInfo()
1043 /// Used to serialize the on-disk global function table.
1052 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
1053 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
1066 void emitUnversionedInfo(raw_ostream &OS, const GlobalFunctionInfo &GFI) { in emitUnversionedInfo() argument
1067 emitFunctionInfo(OS, GFI); in emitUnversionedInfo()
1081 uint32_t Offset; in writeGlobalFunctionBlock() local
1088 // Make sure that no bucket is at offset 0 in writeGlobalFunctionBlock()
1091 Offset = Generator.Emit(BlobStream); in writeGlobalFunctionBlock()
1095 GlobalFunctionData.emit(Scratch, Offset, HashTableBlob); in writeGlobalFunctionBlock()
1100 /// Used to serialize the on-disk global enum constant.
1107 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
1108 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
1120 void emitUnversionedInfo(raw_ostream &OS, const EnumConstantInfo &ECI) { in emitUnversionedInfo() argument
1121 emitCommonEntityInfo(OS, ECI); in emitUnversionedInfo()
1135 uint32_t Offset; in writeEnumConstantBlock() local
1142 // Make sure that no bucket is at offset 0 in writeEnumConstantBlock()
1145 Offset = Generator.Emit(BlobStream); in writeEnumConstantBlock()
1149 EnumConstantData.emit(Scratch, Offset, HashTableBlob); in writeEnumConstantBlock()
1166 void EmitKey(raw_ostream &OS, key_type_ref Key, unsigned) { in EmitKey() argument
1167 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in EmitKey()
1180 void emitUnversionedInfo(raw_ostream &OS, const UnversionedDataType &UDT) { in emitUnversionedInfo() argument
1181 emitCommonTypeInfo(OS, UDT); in emitUnversionedInfo()
1185 /// Used to serialize the on-disk tag table.
1189 return 2 + (TI.SwiftImportAs ? TI.SwiftImportAs->size() : 0) + in getUnversionedInfoSize()
1190 2 + (TI.SwiftRetainOp ? TI.SwiftRetainOp->size() : 0) + in getUnversionedInfoSize()
1191 2 + (TI.SwiftReleaseOp ? TI.SwiftReleaseOp->size() : 0) + in getUnversionedInfoSize()
1195 void emitUnversionedInfo(raw_ostream &OS, const TagInfo &TI) { in emitUnversionedInfo() argument
1196 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitUnversionedInfo()
1216 writer.write<uint16_t>(ImportAs->size() + 1); in emitUnversionedInfo()
1217 OS.write(ImportAs->c_str(), ImportAs->size()); in emitUnversionedInfo()
1222 writer.write<uint16_t>(RetainOp->size() + 1); in emitUnversionedInfo()
1223 OS.write(RetainOp->c_str(), RetainOp->size()); in emitUnversionedInfo()
1228 writer.write<uint16_t>(ReleaseOp->size() + 1); in emitUnversionedInfo()
1229 OS.write(ReleaseOp->c_str(), ReleaseOp->size()); in emitUnversionedInfo()
1234 emitCommonTypeInfo(OS, TI); in emitUnversionedInfo()
1248 uint32_t Offset; in writeTagBlock() local
1255 // Make sure that no bucket is at offset 0 in writeTagBlock()
1258 Offset = Generator.Emit(BlobStream); in writeTagBlock()
1262 TagData.emit(Scratch, Offset, HashTableBlob); in writeTagBlock()
1267 /// Used to serialize the on-disk typedef table.
1275 void emitUnversionedInfo(raw_ostream &OS, const TypedefInfo &TI) { in emitUnversionedInfo() argument
1276 llvm::support::endian::Writer writer(OS, llvm::endianness::little); in emitUnversionedInfo()
1284 emitCommonTypeInfo(OS, TI); in emitUnversionedInfo()
1298 uint32_t Offset; in writeTypedefBlock() local
1305 // Make sure that no bucket is at offset 0 in writeTypedefBlock()
1308 Offset = Generator.Emit(BlobStream); in writeTypedefBlock()
1312 TypedefData.emit(Scratch, Offset, HashTableBlob); in writeTypedefBlock()
1323 void APINotesWriter::writeToStream(llvm::raw_ostream &OS) { in writeToStream() argument
1324 Implementation->writeToStream(OS); in writeToStream()
1331 IdentifierID NameID = Implementation->getIdentifier(Name); in addContext()
1333 uint32_t RawParentCtxID = ParentCtxID ? ParentCtxID->Value : -1; in addContext()
1335 auto Known = Implementation->Contexts.find(Key); in addContext()
1336 if (Known == Implementation->Contexts.end()) { in addContext()
1337 unsigned NextID = Implementation->Contexts.size() + 1; in addContext()
1340 Known = Implementation->Contexts in addContext()
1345 Implementation->ContextNames[NextID] = NameID; in addContext()
1346 Implementation->ParentContexts[NextID] = RawParentCtxID; in addContext()
1350 auto &VersionedVec = Known->second.second; in addContext()
1363 return ContextID(Known->second.first); in addContext()
1370 IdentifierID NameID = Implementation->getIdentifier(Name); in addObjCProperty()
1372 ->ObjCProperties[std::make_tuple(CtxID.Value, NameID, IsInstanceProperty)] in addObjCProperty()
1380 SelectorID SelID = Implementation->getSelector(Selector); in addObjCMethod()
1383 Implementation->ObjCMethods[Key].push_back({SwiftVersion, Info}); in addObjCMethod()
1388 assert(Implementation->ParentContexts.contains(CtxID.Value)); in addObjCMethod()
1389 uint32_t ParentCtxID = Implementation->ParentContexts[CtxID.Value]; in addObjCMethod()
1392 Implementation->ContextNames[CtxID.Value]); in addObjCMethod()
1393 assert(Implementation->Contexts.contains(CtxKey)); in addObjCMethod()
1394 auto &VersionedVec = Implementation->Contexts[CtxKey].second; in addObjCMethod()
1414 IdentifierID NameID = Implementation->getIdentifier(Name); in addCXXMethod()
1416 Implementation->CXXMethods[Key].push_back({SwiftVersion, Info}); in addCXXMethod()
1423 IdentifierID VariableID = Implementation->getIdentifier(Name); in addGlobalVariable()
1425 Implementation->GlobalVariables[Key].push_back({SwiftVersion, Info}); in addGlobalVariable()
1432 IdentifierID NameID = Implementation->getIdentifier(Name); in addGlobalFunction()
1434 Implementation->GlobalFunctions[Key].push_back({SwiftVersion, Info}); in addGlobalFunction()
1440 IdentifierID EnumConstantID = Implementation->getIdentifier(Name); in addEnumConstant()
1441 Implementation->EnumConstants[EnumConstantID].push_back({SwiftVersion, Info}); in addEnumConstant()
1446 IdentifierID TagID = Implementation->getIdentifier(Name); in addTag()
1448 Implementation->Tags[Key].push_back({SwiftVersion, Info}); in addTag()
1454 IdentifierID TypedefID = Implementation->getIdentifier(Name); in addTypedef()
1456 Implementation->Typedefs[Key].push_back({SwiftVersion, Info}); in addTypedef()