LLVM 22.0.0git
|
Defines the interface file. More...
#include "llvm/TextAPI/InterfaceFile.h"
Public Types | |
using | const_target_iterator = TargetList::const_iterator |
using | const_target_range = llvm::iterator_range< const_target_iterator > |
using | const_filtered_target_iterator = llvm::filter_iterator< const_target_iterator, std::function< bool(const Target &)> > |
using | const_filtered_target_range = llvm::iterator_range< const_filtered_target_iterator > |
using | const_symbol_range = SymbolSet::const_symbol_range |
using | const_filtered_symbol_range = SymbolSet::const_filtered_symbol_range |
Public Member Functions | |
InterfaceFile (std::unique_ptr< SymbolSet > &&InputSymbols) | |
InterfaceFile () | |
void | setPath (StringRef Path_) |
Set the path from which this file was generated (if applicable). | |
StringRef | getPath () const |
Get the path from which this file was generated (if applicable). | |
void | setFileType (FileType Kind) |
Set the file type. | |
FileType | getFileType () const |
Get the file type. | |
ArchitectureSet | getArchitectures () const |
Get the architectures. | |
PlatformSet | getPlatforms () const |
Get the platforms. | |
LLVM_ABI void | addTarget (const Target &Target) |
Set and add target. | |
bool | hasTarget (const Target &Targ) const |
Determine if target triple slice exists in file. | |
template<typename RangeT > | |
void | addTargets (RangeT &&Targets) |
Set and add targets. | |
const_target_range | targets () const |
LLVM_ABI const_filtered_target_range | targets (ArchitectureSet Archs) const |
void | setInstallName (StringRef InstallName_) |
Set the install name of the library. | |
StringRef | getInstallName () const |
Get the install name of the library. | |
void | setCurrentVersion (PackedVersion Version) |
Set the current version of the library. | |
PackedVersion | getCurrentVersion () const |
Get the current version of the library. | |
void | setCompatibilityVersion (PackedVersion Version) |
Set the compatibility version of the library. | |
PackedVersion | getCompatibilityVersion () const |
Get the compatibility version of the library. | |
void | setSwiftABIVersion (uint8_t Version) |
Set the Swift ABI version of the library. | |
uint8_t | getSwiftABIVersion () const |
Get the Swift ABI version of the library. | |
void | setTwoLevelNamespace (bool V=true) |
Specify if the library uses two-level namespace (or flat namespace). | |
bool | isTwoLevelNamespace () const |
Check if the library uses two-level namespace. | |
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. | |
void | setApplicationExtensionSafe (bool V=true) |
Specify if the library is application extension safe (or not). | |
bool | isApplicationExtensionSafe () const |
Check if the library is application extension safe. | |
bool | hasSimulatorSupport () const |
Check if the library has simulator support. | |
void | setSimulatorSupport (bool V=true) |
Specify if the library has simulator support. | |
void | setObjCConstraint (ObjCConstraintType Constraint) |
Set the Objective-C constraint. | |
ObjCConstraintType | getObjCConstraint () const |
Get the Objective-C constraint. | |
LLVM_ABI void | addParentUmbrella (const Target &Target_, StringRef Parent) |
Set the parent umbrella frameworks. | |
const std::vector< std::pair< Target, std::string > > & | umbrellas () const |
Get the list of Parent Umbrella frameworks. | |
LLVM_ABI void | addAllowableClient (StringRef InstallName, const Target &Target) |
Add an allowable client. | |
const std::vector< InterfaceFileRef > & | allowableClients () const |
Get the list of allowable clients. | |
LLVM_ABI void | addReexportedLibrary (StringRef InstallName, const Target &Target) |
Add a re-exported library. | |
const std::vector< InterfaceFileRef > & | reexportedLibraries () const |
Get the list of re-exported libraries. | |
LLVM_ABI void | addDocument (std::shared_ptr< InterfaceFile > &&Document) |
Add a library for inlining to top level library. | |
InterfaceFile * | getParent () const |
Returns the pointer to parent document if exists or nullptr otherwise. | |
const std::vector< std::shared_ptr< InterfaceFile > > & | documents () const |
Get the list of inlined libraries. | |
LLVM_ABI void | addRPath (StringRef RPath, const Target &InputTarget) |
Set the runpath search paths. | |
const std::vector< std::pair< Target, std::string > > & | rpaths () const |
Get the list of runpath search paths. | |
std::optional< const Symbol * > | getSymbol (EncodeKind Kind, StringRef Name, ObjCIFSymbolKind ObjCIF=ObjCIFSymbolKind::None) const |
Get symbol if exists in file. | |
template<typename RangeT , typename ElT = std::remove_reference_t< decltype(*std::begin(std::declval<RangeT>()))>> | |
void | addSymbol (EncodeKind Kind, StringRef Name, RangeT &&Targets, SymbolFlags Flags=SymbolFlags::None) |
Add a symbol to the symbols list or extend an existing one. | |
void | addSymbol (EncodeKind Kind, StringRef Name, TargetList &&Targets, SymbolFlags Flags=SymbolFlags::None) |
Add Symbol with multiple targets. | |
void | addSymbol (EncodeKind Kind, StringRef Name, Target &Target, SymbolFlags Flags=SymbolFlags::None) |
Add Symbol with single target. | |
size_t | symbolsCount () const |
Get size of symbol set. | |
const_symbol_range | symbols () const |
const_filtered_symbol_range | exports () const |
const_filtered_symbol_range | reexports () const |
const_filtered_symbol_range | undefineds () const |
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > | extract (Architecture Arch) const |
Extract architecture slice from Interface. | |
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > | remove (Architecture Arch) const |
Remove architecture slice from Interface. | |
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > | merge (const InterfaceFile *O) const |
Merge Interfaces for the same library. | |
LLVM_ABI void | inlineLibrary (std::shared_ptr< InterfaceFile > Library, bool Overwrite=false) |
Inline reexported library into Interface. | |
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 bool | operator== (const InterfaceFile &O) const |
The equality is determined by attributes that impact linking compatibilities. | |
bool | operator!= (const InterfaceFile &O) const |
Defines the interface file.
Definition at line 106 of file InterfaceFile.h.
using llvm::MachO::InterfaceFile::const_filtered_symbol_range = SymbolSet::const_filtered_symbol_range |
Definition at line 363 of file InterfaceFile.h.
using llvm::MachO::InterfaceFile::const_filtered_target_iterator = llvm::filter_iterator<const_target_iterator, std::function<bool(const Target &)> > |
Definition at line 173 of file InterfaceFile.h.
using llvm::MachO::InterfaceFile::const_filtered_target_range = llvm::iterator_range<const_filtered_target_iterator> |
Definition at line 176 of file InterfaceFile.h.
Definition at line 362 of file InterfaceFile.h.
Definition at line 169 of file InterfaceFile.h.
Definition at line 170 of file InterfaceFile.h.
|
inline |
Definition at line 108 of file InterfaceFile.h.
|
inline |
Definition at line 111 of file InterfaceFile.h.
Add an allowable client.
Mach-O Dynamic libraries have the concept of allowable clients that are checked during static link time. The name of the application or library that is being generated needs to match one of the allowable clients or the linker refuses to link this library.
InstallName | The name of the client that is allowed to link this library. |
Target | The target triple for which this applies. |
Definition at line 24 of file InterfaceFile.cpp.
References llvm::MachO::addEntry(), and llvm::StringRef::empty().
Referenced by setFromBinaryAttrs().
void InterfaceFile::addDocument | ( | std::shared_ptr< InterfaceFile > && | Document | ) |
Add a library for inlining to top level library.
Document | The library to inline with top level library. |
Definition at line 79 of file InterfaceFile.cpp.
References assert(), LHS, llvm::lower_bound(), and RHS.
Set the parent umbrella frameworks.
Target_ | The target applicable to Parent |
Parent | The name of Parent |
Definition at line 40 of file InterfaceFile.cpp.
References llvm::StringRef::empty(), LHS, llvm::lower_bound(), and RHS.
Referenced by setFromBinaryAttrs().
Add a re-exported library.
InstallName | The name of the library to re-export. |
Target | The target triple for which this applies. |
Definition at line 32 of file InterfaceFile.cpp.
References llvm::MachO::addEntry(), llvm::StringRef::empty(), and llvm::Lib.
Referenced by setFromBinaryAttrs().
Set the runpath search paths.
RPath | The name of runpath. |
InputTarget | The target applicable to runpath search path. |
Definition at line 55 of file InterfaceFile.cpp.
References llvm::StringRef::empty(), and llvm::is_contained().
|
inline |
Add a symbol to the symbols list or extend an existing one.
Definition at line 331 of file InterfaceFile.h.
References Name.
|
inline |
Add Symbol with single target.
Kind | The kind of global symbol to record. |
Name | The name of the symbol. |
Target | The target the symbol is defined in. |
Flags | The properties the symbol holds. |
Definition at line 353 of file InterfaceFile.h.
References Name.
|
inline |
Add Symbol with multiple targets.
Kind | The kind of global symbol to record. |
Name | The name of the symbol. |
Targets | The list of targets the symbol is defined in. |
Flags | The properties the symbol holds. |
Definition at line 342 of file InterfaceFile.h.
References Name.
Set and add target.
Target | the target to add into. |
Definition at line 67 of file InterfaceFile.cpp.
References llvm::MachO::addEntry().
Referenced by addTargets().
|
inline |
Set and add targets.
Add the subset of llvm::triples that is supported by Tapi
Targets | the collection of targets. |
Definition at line 164 of file InterfaceFile.h.
References addTarget().
|
inline |
Get the list of allowable clients.
Definition at line 270 of file InterfaceFile.h.
|
inline |
Get the list of inlined libraries.
Definition at line 299 of file InterfaceFile.h.
|
inline |
Definition at line 366 of file InterfaceFile.h.
Expected< std::unique_ptr< InterfaceFile > > InterfaceFile::extract | ( | Architecture | Arch | ) | const |
Extract architecture slice from Interface.
Arch | architecture to extract from. |
Definition at line 300 of file InterfaceFile.cpp.
References allowableClients(), llvm::MachO::Target::Arch, llvm::MachO::getArchitectureName(), getArchitectures(), getCompatibilityVersion(), getCurrentVersion(), getFileType(), llvm::MachO::Symbol::getFlags(), getInstallName(), llvm::MachO::Symbol::getKind(), llvm::MachO::Symbol::getName(), getPath(), getSwiftABIVersion(), llvm::MachO::Symbol::hasArchitecture(), llvm::inconvertibleErrorCode(), InterfaceFile(), isApplicationExtensionSafe(), isOSLibNotForSharedCache(), isTwoLevelNamespace(), llvm::Lib, reexportedLibraries(), rpaths(), Sym, symbols(), targets(), llvm::MachO::Symbol::targets(), and umbrellas().
|
inline |
Get the architectures.
Definition at line 138 of file InterfaceFile.h.
References llvm::MachO::mapToArchitectureSet().
|
inline |
Get the compatibility version of the library.
Definition at line 200 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Get the current version of the library.
Definition at line 192 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Get the file type.
Definition at line 133 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Get the install name of the library.
Definition at line 186 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Get the Objective-C constraint.
Definition at line 240 of file InterfaceFile.h.
|
inline |
Returns the pointer to parent document if exists or nullptr otherwise.
Definition at line 294 of file InterfaceFile.h.
|
inline |
Get the path from which this file was generated (if applicable).
Definition at line 120 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Get the platforms.
Definition at line 145 of file InterfaceFile.h.
References llvm::MachO::mapToPlatformSet().
|
inline |
Get the Swift ABI version of the library.
Definition at line 206 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Get symbol if exists in file.
Kind | The kind of global symbol to record. |
Name | The name of the symbol. |
ObjCIF | The ObjCInterface symbol type, if applicable. |
Definition at line 321 of file InterfaceFile.h.
|
inline |
Check if the library has simulator support.
Definition at line 229 of file InterfaceFile.h.
Determine if target triple slice exists in file.
Targ | the value to find. |
Definition at line 155 of file InterfaceFile.h.
References llvm::is_contained().
void InterfaceFile::inlineLibrary | ( | std::shared_ptr< InterfaceFile > | Library, |
bool | Overwrite = false |
||
) |
Inline reexported library into Interface.
Library | Interface of reexported library. |
Overwrite | Whether to overwrite preexisting inlined library. |
Definition at line 92 of file InterfaceFile.cpp.
References llvm::lower_bound(), and llvm::replace().
|
inline |
Check if the library is application extension safe.
Definition at line 226 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Check if the library is an OS library that is not shared cache eligible.
Definition at line 220 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
|
inline |
Check if the library uses two-level namespace.
Definition at line 212 of file InterfaceFile.h.
Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().
Expected< std::unique_ptr< InterfaceFile > > InterfaceFile::merge | ( | const InterfaceFile * | O | ) | const |
Merge Interfaces for the same library.
The following library attributes must match.
O | The Interface to merge. |
Definition at line 121 of file InterfaceFile.cpp.
References allowableClients(), getCompatibilityVersion(), getCurrentVersion(), getFileType(), llvm::MachO::Symbol::getFlags(), getInstallName(), llvm::MachO::Symbol::getKind(), llvm::MachO::Symbol::getName(), getPath(), getSwiftABIVersion(), llvm::inconvertibleErrorCode(), InterfaceFile(), isApplicationExtensionSafe(), isOSLibNotForSharedCache(), isTwoLevelNamespace(), llvm::Lib, reexportedLibraries(), rpaths(), Sym, symbols(), targets(), llvm::MachO::Symbol::targets(), and umbrellas().
|
inline |
Definition at line 419 of file InterfaceFile.h.
bool InterfaceFile::operator== | ( | const InterfaceFile & | O | ) | const |
The equality is determined by attributes that impact linking compatibilities.
Path, & FileKind are irrelevant since these by itself should not impact linking. This is an expensive operation.
Definition at line 389 of file InterfaceFile.cpp.
References isYAMLTextStub(), LHS, llvm::MachO::mapToPlatformVersionSet(), and RHS.
|
inline |
Get the list of re-exported libraries.
Definition at line 284 of file InterfaceFile.h.
|
inline |
Definition at line 367 of file InterfaceFile.h.
Expected< std::unique_ptr< InterfaceFile > > InterfaceFile::remove | ( | Architecture | Arch | ) | const |
Remove architecture slice from Interface.
Arch | architecture to remove. |
Definition at line 217 of file InterfaceFile.cpp.
References llvm::MachO::ArchitectureSet::All(), allowableClients(), llvm::MachO::Target::Arch, llvm::MachO::ArchitectureSet::clear(), llvm::MachO::getArchitectureName(), getArchitectures(), llvm::MachO::Symbol::getArchitectures(), getCompatibilityVersion(), getCurrentVersion(), getFileType(), llvm::MachO::Symbol::getFlags(), getInstallName(), llvm::MachO::Symbol::getKind(), llvm::MachO::Symbol::getName(), getPath(), getSwiftABIVersion(), llvm::inconvertibleErrorCode(), InterfaceFile(), isApplicationExtensionSafe(), isOSLibNotForSharedCache(), isTwoLevelNamespace(), llvm::Lib, llvm::MachO::NoSuchArchitecture, reexportedLibraries(), Sym, symbols(), targets(), llvm::MachO::Symbol::targets(), and umbrellas().
|
inline |
Get the list of runpath search paths.
Definition at line 311 of file InterfaceFile.h.
|
inline |
Specify if the library is application extension safe (or not).
Definition at line 223 of file InterfaceFile.h.
Referenced by setFromBinaryAttrs().
|
inline |
Set the compatibility version of the library.
Definition at line 195 of file InterfaceFile.h.
References llvm::Version.
Referenced by setFromBinaryAttrs().
|
inline |
Set the current version of the library.
Definition at line 189 of file InterfaceFile.h.
References llvm::Version.
Referenced by setFromBinaryAttrs().
|
inline |
Set the file type.
This is used by the YAML writer to identify the specification it should use for writing the file.
Kind | The file type. |
Definition at line 128 of file InterfaceFile.h.
Referenced by setFromBinaryAttrs().
void InterfaceFile::setFromBinaryAttrs | ( | const RecordsSlice::BinaryAttrs & | BA, |
const Target & | Targ | ||
) |
Set InterfaceFile properties from pre-gathered binary attributes, if they are not set already.
BA | Attributes typically represented in load commands. |
Targ | MachO Target slice to add attributes to. |
Definition at line 357 of file InterfaceFile.cpp.
References addAllowableClient(), addParentUmbrella(), addReexportedLibrary(), llvm::MachO::RecordsSlice::BinaryAttrs::AllowableClients, llvm::MachO::RecordsSlice::BinaryAttrs::AppExtensionSafe, llvm::MachO::RecordsSlice::BinaryAttrs::CompatVersion, llvm::MachO::RecordsSlice::BinaryAttrs::CurrentVersion, llvm::StringRef::empty(), llvm::MachO::RecordsSlice::BinaryAttrs::File, getCompatibilityVersion(), getCurrentVersion(), getFileType(), getInstallName(), getPath(), getSwiftABIVersion(), llvm::MachO::RecordsSlice::BinaryAttrs::InstallName, isApplicationExtensionSafe(), isOSLibNotForSharedCache(), isTwoLevelNamespace(), llvm::Lib, llvm::MachO::RecordsSlice::BinaryAttrs::OSLibNotForSharedCache, llvm::MachO::RecordsSlice::BinaryAttrs::ParentUmbrella, llvm::MachO::RecordsSlice::BinaryAttrs::Path, llvm::MachO::RecordsSlice::BinaryAttrs::RexportedLibraries, setApplicationExtensionSafe(), setCompatibilityVersion(), setCurrentVersion(), setFileType(), setInstallName(), setOSLibNotForSharedCache(), setPath(), setSwiftABIVersion(), setTwoLevelNamespace(), llvm::MachO::RecordsSlice::BinaryAttrs::SwiftABI, and llvm::MachO::RecordsSlice::BinaryAttrs::TwoLevelNamespace.
|
inline |
Set the install name of the library.
Definition at line 181 of file InterfaceFile.h.
Referenced by setFromBinaryAttrs().
|
inline |
Set the Objective-C constraint.
Definition at line 235 of file InterfaceFile.h.
|
inline |
Specify if the library is an OS library but not shared cache eligible.
Definition at line 215 of file InterfaceFile.h.
Referenced by setFromBinaryAttrs().
|
inline |
Set the path from which this file was generated (if applicable).
Path_ | The path to the source file. |
Definition at line 115 of file InterfaceFile.h.
Referenced by setFromBinaryAttrs().
|
inline |
Specify if the library has simulator support.
Definition at line 232 of file InterfaceFile.h.
|
inline |
Set the Swift ABI version of the library.
Definition at line 203 of file InterfaceFile.h.
References llvm::Version.
Referenced by setFromBinaryAttrs().
|
inline |
Specify if the library uses two-level namespace (or flat namespace).
Definition at line 209 of file InterfaceFile.h.
Referenced by setFromBinaryAttrs().
|
inline |
Definition at line 365 of file InterfaceFile.h.
|
inline |
Get size of symbol set.
Definition at line 360 of file InterfaceFile.h.
|
inline |
Definition at line 171 of file InterfaceFile.h.
InterfaceFile::const_filtered_target_range InterfaceFile::targets | ( | ArchitectureSet | Archs | ) | const |
Definition at line 72 of file InterfaceFile.cpp.
References llvm::MachO::ArchitectureSet::has(), and llvm::make_filter_range().
|
inline |
Get the list of Parent Umbrella frameworks.
Definition at line 251 of file InterfaceFile.h.
|
inline |
Definition at line 370 of file InterfaceFile.h.