26 if (InstallName.
empty())
28 auto Client =
addEntry(AllowableClients, InstallName);
34 if (InstallName.
empty())
36 auto Lib =
addEntry(ReexportedLibraries, InstallName);
44 [](
const std::pair<Target, std::string> &
LHS,
47 if ((Iter != ParentUmbrellas.end()) && !(Target_ < Iter->first)) {
48 Iter->second = std::string(Parent);
52 ParentUmbrellas.emplace(Iter, Target_, std::string(Parent));
58 using RPathEntryT =
const std::pair<Target, std::string>;
59 RPathEntryT Entry(InputTarget, RPath);
64 RPaths.emplace_back(Entry);
74 return Archs.
has(Target_.Arch);
81 [](
const std::shared_ptr<InterfaceFile> &
LHS,
82 const std::shared_ptr<InterfaceFile> &
RHS) {
83 return LHS->InstallName <
RHS->InstallName;
85 assert((Pos == Documents.end() ||
86 (*Pos)->InstallName != Document->InstallName) &&
87 "Unexpected duplicate document added");
88 Document->Parent =
this;
89 Documents.insert(Pos, Document);
94 auto AddFwk = [&](std::shared_ptr<InterfaceFile> &&Reexport) {
96 Documents, Reexport->getInstallName(),
97 [](std::shared_ptr<InterfaceFile> &Lhs,
const StringRef Rhs) {
98 return Lhs->getInstallName() < Rhs;
101 if (Overwrite && It != Documents.end() &&
102 Reexport->getInstallName() == (*It)->getInstallName()) {
107 if ((It != Documents.end()) &&
108 !(Reexport->getInstallName() < (*It)->getInstallName()))
111 Documents.emplace(It, std::move(Reexport));
113 for (
auto Doc : Library->documents())
114 AddFwk(std::move(Doc));
116 Library->Documents.clear();
117 AddFwk(std::move(Library));
124 return make_error<StringError>(
"install names do not match",
129 return make_error<StringError>(
"current versions do not match",
134 return make_error<StringError>(
"compatibility versions do not match",
140 return make_error<StringError>(
"swift ABI versions do not match",
145 return make_error<StringError>(
"two level namespace flags do not match",
150 return make_error<StringError>(
151 "application extension safe flags do not match",
156 IF->setFileType(std::max(
getFileType(), O->getFileType()));
163 IF->setSwiftABIVersion(O->getSwiftABIVersion());
172 if (!It.second.empty())
173 IF->addParentUmbrella(It.first, It.second);
175 for (
const auto &It : O->umbrellas()) {
176 if (!It.second.empty())
177 IF->addParentUmbrella(It.first, It.second);
180 IF->addTargets(O->targets());
184 IF->addAllowableClient(
Lib.getInstallName(),
Target);
186 for (
const auto &
Lib : O->allowableClients())
188 IF->addAllowableClient(
Lib.getInstallName(),
Target);
192 IF->addReexportedLibrary(
Lib.getInstallName(),
Target);
194 for (
const auto &
Lib : O->reexportedLibraries())
196 IF->addReexportedLibrary(
Lib.getInstallName(),
Target);
199 IF->addRPath(Path,
Target);
200 for (
const auto &[
Target, Path] : O->rpaths())
201 IF->addRPath(Path,
Target);
208 for (
const auto *
Sym : O->symbols()) {
213 return std::move(IF);
219 return make_error<StringError>(
"cannot remove last architecture slice '" +
225 for (
auto &Doc : Documents) {
226 if (Doc->getArchitectures().has(Arch)) {
250 if (It.first.Arch != Arch)
251 IF->addParentUmbrella(It.first, It.second);
256 IF->addAllowableClient(
Lib.getInstallName(),
Target);
262 IF->addReexportedLibrary(
Lib.getInstallName(),
Target);
275 for (
auto &Doc : Documents) {
278 if (Doc->getArchitectures() == Arch)
283 if (!Doc->getArchitectures().has(Arch)) {
285 IF->addDocument(std::move(NewDoc));
289 auto Result = Doc->remove(Arch);
293 IF->addDocument(std::move(Result.get()));
296 return std::move(IF);
302 return make_error<StringError>(
"file doesn't have architecture '" +
319 if (It.first.Arch == Arch)
320 IF->addParentUmbrella(It.first, It.second);
322 for (
const auto &It :
rpaths())
323 if (It.first.Arch == Arch)
324 IF->addRPath(It.second, It.first);
329 IF->addAllowableClient(
Lib.getInstallName(),
Target);
334 IF->addReexportedLibrary(
Lib.getInstallName(),
Target);
342 for (
auto &Doc : Documents) {
344 if (!Doc->getArchitectures().has(Arch))
347 auto Result = Doc->extract(Arch);
351 IF->addDocument(std::move(Result.get()));
354 return std::move(IF);
390 if (Targets != O.Targets)
392 if (InstallName != O.InstallName)
394 if ((CurrentVersion != O.CurrentVersion) ||
395 (CompatibilityVersion != O.CompatibilityVersion))
397 if (SwiftABIVersion != O.SwiftABIVersion)
399 if (IsTwoLevelNamespace != O.IsTwoLevelNamespace)
401 if (IsAppExtensionSafe != O.IsAppExtensionSafe)
403 if (IsOSLibNotForSharedCache != O.IsOSLibNotForSharedCache)
405 if (HasSimSupport != O.HasSimSupport)
407 if (ParentUmbrellas != O.ParentUmbrellas)
409 if (AllowableClients != O.AllowableClients)
411 if (ReexportedLibraries != O.ReexportedLibraries)
413 if (*SymbolsSet != *O.SymbolsSet)
418 if (RPaths != O.RPaths)
424 if (!std::equal(Documents.begin(), Documents.end(), O.Documents.begin(),
426 [](
const std::shared_ptr<InterfaceFile>
LHS,
427 const std::shared_ptr<InterfaceFile>
RHS) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isYAMLTextStub(const FileType &Kind)
Implements the TAPI Record Collection Type.
Define TAPI specific error codes.
Tagged union holding either a T or a Error.
static ArchitectureSet All()
ArchitectureSet clear(Architecture Arch)
bool has(Architecture Arch) const
LLVM_ABI void addTarget(const Target &Target)
Defines the interface file.
LLVM_ABI void addDocument(std::shared_ptr< InterfaceFile > &&Document)
Add a library for inlining to top level library.
StringRef getPath() const
Get the path from which this file was generated (if applicable).
LLVM_ABI void addReexportedLibrary(StringRef InstallName, const Target &Target)
Add a re-exported library.
void setPath(StringRef Path_)
Set the path from which this file was generated (if applicable).
LLVM_ABI void setFromBinaryAttrs(const RecordsSlice::BinaryAttrs &BA, const Target &Targ)
Set InterfaceFile properties from pre-gathered binary attributes, if they are not set already.
LLVM_ABI void addParentUmbrella(const Target &Target_, StringRef Parent)
Set the parent umbrella frameworks.
const_target_range targets() const
void setOSLibNotForSharedCache(bool V=true)
Specify if the library is an OS library but not shared cache eligible.
bool isOSLibNotForSharedCache() const
Check if the library is an OS library that is not shared cache eligible.
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > remove(Architecture Arch) const
Remove architecture slice from Interface.
bool isTwoLevelNamespace() const
Check if the library uses two-level namespace.
LLVM_ABI bool operator==(const InterfaceFile &O) const
The equality is determined by attributes that impact linking compatibilities.
PackedVersion getCompatibilityVersion() const
Get the compatibility version of the library.
LLVM_ABI void addTarget(const Target &Target)
Set and add target.
bool isApplicationExtensionSafe() const
Check if the library is application extension safe.
const std::vector< std::pair< Target, std::string > > & rpaths() const
Get the list of runpath search paths.
const std::vector< InterfaceFileRef > & allowableClients() const
Get the list of allowable clients.
void setInstallName(StringRef InstallName_)
Set the install name of the library.
const std::vector< std::pair< Target, std::string > > & umbrellas() const
Get the list of Parent Umbrella frameworks.
const std::vector< InterfaceFileRef > & reexportedLibraries() const
Get the list of re-exported libraries.
const_symbol_range symbols() const
void setFileType(FileType Kind)
Set the file type.
uint8_t getSwiftABIVersion() const
Get the Swift ABI version of the library.
PackedVersion getCurrentVersion() const
Get the current version of the library.
LLVM_ABI void addRPath(StringRef RPath, const Target &InputTarget)
Set the runpath search paths.
void setCompatibilityVersion(PackedVersion Version)
Set the compatibility version of the library.
ArchitectureSet getArchitectures() const
Get the architectures.
StringRef getInstallName() const
Get the install name of the library.
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > merge(const InterfaceFile *O) const
Merge Interfaces for the same library.
FileType getFileType() const
Get the file type.
void setApplicationExtensionSafe(bool V=true)
Specify if the library is application extension safe (or not).
LLVM_ABI void addAllowableClient(StringRef InstallName, const Target &Target)
Add an allowable client.
LLVM_ABI void inlineLibrary(std::shared_ptr< InterfaceFile > Library, bool Overwrite=false)
Inline reexported library into Interface.
void setSwiftABIVersion(uint8_t Version)
Set the Swift ABI version of the library.
void setCurrentVersion(PackedVersion Version)
Set the current version of the library.
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > extract(Architecture Arch) const
Extract architecture slice from Interface.
void setTwoLevelNamespace(bool V=true)
Specify if the library uses two-level namespace (or flat namespace).
SymbolFlags getFlags() const
bool hasArchitecture(Architecture Arch) const
const_target_range targets() const
ArchitectureSet getArchitectures() const
StringRef getName() const
EncodeKind getKind() const
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
A range adaptor for a pair of iterators.
FileType
Defines the file type TextAPI files can represent.
@ TBD_V1
Text-based stub file (.tbd) version 1.0.
@ TBD_V5
Text-based stub file (.tbd) version 5.0.
LLVM_ABI StringRef getArchitectureName(Architecture Arch)
Convert an architecture slice to a string.
C::iterator addEntry(C &Container, StringRef InstallName)
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
LLVM_ABI PlatformVersionSet mapToPlatformVersionSet(ArrayRef< Target > Targets)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
void replace(R &&Range, const T &OldValue, const T &NewValue)
Provide wrappers to std::replace which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
std::vector< StringRef > RexportedLibraries
std::vector< StringRef > AllowableClients
llvm::MachO::PackedVersion CompatVersion
llvm::MachO::PackedVersion CurrentVersion
bool OSLibNotForSharedCache