================ @@ -1200,5 +1235,128 @@ APINotesWriter::~APINotesWriter() = default; void APINotesWriter::writeToStream(llvm::raw_ostream &OS) { Implementation->writeToStream(OS); } + +ContextID APINotesWriter::addObjCContext(std::optional<ContextID> ParentCtxID, + StringRef Name, ContextKind Kind, + const ObjCContextInfo &Info, + VersionTuple SwiftVersion) { + IdentifierID NameID = Implementation->getIdentifier(Name); + + uint32_t RawParentCtxID = ParentCtxID ? ParentCtxID->Value : -1; + ContextTableKey Key(RawParentCtxID, (uint8_t)Kind, NameID); + auto Known = Implementation->ObjCContexts.find(Key); + if (Known == Implementation->ObjCContexts.end()) { + unsigned NextID = Implementation->ObjCContexts.size() + 1; + + VersionedSmallVector<ObjCContextInfo> EmptyVersionedInfo; + Known = Implementation->ObjCContexts + .insert(std::make_pair( + Key, std::make_pair(NextID, EmptyVersionedInfo))) + .first; + + Implementation->ObjCContextNames[NextID] = NameID; + Implementation->ParentContexts[NextID] = RawParentCtxID; + } + + // Add this version information. + auto &VersionedVec = Known->second.second; + bool Found = false; + for (auto &Versioned : VersionedVec) { + if (Versioned.first == SwiftVersion) { + Versioned.second |= Info; + Found = true; + break; + } + } + + if (!Found) + VersionedVec.push_back({SwiftVersion, Info}); + + return ContextID(Known->second.first); +} + +void APINotesWriter::addObjCProperty(ContextID CtxID, StringRef Name, + bool IsInstanceProperty, + const ObjCPropertyInfo &Info, + VersionTuple SwiftVersion) { + IdentifierID NameID = Implementation->getIdentifier(Name); + Implementation + ->ObjCProperties[std::make_tuple(CtxID.Value, NameID, IsInstanceProperty)] + .push_back({SwiftVersion, Info}); +} + +void APINotesWriter::addObjCMethod(ContextID CtxID, ObjCSelectorRef Selector, + bool IsInstanceMethod, + const ObjCMethodInfo &Info, + VersionTuple SwiftVersion) { + SelectorID SelID = Implementation->getSelector(Selector); + auto Key = std::tuple<unsigned, unsigned, char>{CtxID.Value, SelID, + IsInstanceMethod}; + Implementation->ObjCMethods[Key].push_back({SwiftVersion, Info}); + + // If this method is a designated initializer, update the class to note that + // it has designated initializers. + if (Info.DesignatedInit) { + assert(Implementation->ParentContexts.contains(CtxID.Value)); + uint32_t ParentCtxID = Implementation->ParentContexts[CtxID.Value]; + ContextTableKey CtxKey(ParentCtxID, (uint8_t)ContextKind::ObjCClass, ---------------- egorzhdan wrote:
Done https://github.com/llvm/llvm-project/pull/65187 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits