From 0882c70df222a89c15f2776b85a60696e6ecd712 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Mon, 24 Jul 2023 11:55:01 -0700 Subject: [TextAPI] Introduce SymbolSet SymbolSet is a structure that acts as a simple container class for exported symbols that belong to a library interface. It allows tapi to decouple the globals from the other library attributes. It's uniqued by symbol name and `kind`, which all contain their assigned target triples. Reviewed By: zixuw Differential Revision: https://reviews.llvm.org/D149860 --- llvm/lib/TextAPI/InterfaceFile.cpp | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'llvm/lib/TextAPI/InterfaceFile.cpp') diff --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp index 8c0b65916026..bb98c92f7178 100644 --- a/llvm/lib/TextAPI/InterfaceFile.cpp +++ b/llvm/lib/TextAPI/InterfaceFile.cpp @@ -17,31 +17,6 @@ using namespace llvm; using namespace llvm::MachO; -namespace { -template -typename C::iterator addEntry(C &Container, StringRef InstallName) { - auto I = partition_point(Container, [=](const InterfaceFileRef &O) { - return O.getInstallName() < InstallName; - }); - if (I != Container.end() && I->getInstallName() == InstallName) - return I; - - return Container.emplace(I, InstallName); -} - -template -typename C::iterator addEntry(C &Container, const Target &Target_) { - auto Iter = - lower_bound(Container, Target_, [](const Target &LHS, const Target &RHS) { - return LHS < RHS; - }); - if ((Iter != std::end(Container)) && !(Target_ < *Iter)) - return Iter; - - return Container.insert(Iter, Target_); -} -} // end namespace - void InterfaceFileRef::addTarget(const Target &Target) { addEntry(Targets, Target); } @@ -120,17 +95,6 @@ InterfaceFile::targets(ArchitectureSet Archs) const { return make_filter_range(Targets, fn); } -void InterfaceFile::addSymbol(SymbolKind Kind, StringRef Name, - const TargetList &Targets, SymbolFlags Flags) { - Name = copyString(Name); - auto result = Symbols.try_emplace(SymbolsMapKey{Kind, Name}, nullptr); - if (result.second) - result.first->second = new (Allocator) Symbol{Kind, Name, Targets, Flags}; - else - for (const auto &Target : Targets) - result.first->second->addTarget(Target); -} - void InterfaceFile::addDocument(std::shared_ptr &&Document) { auto Pos = llvm::lower_bound(Documents, Document, [](const std::shared_ptr &LHS, @@ -167,7 +131,7 @@ bool InterfaceFile::operator==(const InterfaceFile &O) const { return false; if (ReexportedLibraries != O.ReexportedLibraries) return false; - if (Symbols != O.Symbols) + if (*SymbolsSet != *O.SymbolsSet) return false; // Don't compare run search paths for older filetypes that cannot express // them. -- cgit v1.2.3