LLVM 20.0.0git
Public Types | Public Member Functions | List of all members
llvm::MachO::InterfaceFile Class Reference

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.
 
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
 
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.
 
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.
 
void addAllowableClient (StringRef InstallName, const Target &Target)
 Add an allowable client.
 
const std::vector< InterfaceFileRef > & allowableClients () const
 Get the list of allowable clients.
 
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.
 
void addDocument (std::shared_ptr< InterfaceFile > &&Document)
 Add a library for inlining to top level library.
 
InterfaceFilegetParent () 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.
 
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::Expected< std::unique_ptr< InterfaceFile > > extract (Architecture Arch) const
 Extract architecture slice from Interface.
 
llvm::Expected< std::unique_ptr< InterfaceFile > > remove (Architecture Arch) const
 Remove architecture slice from Interface.
 
llvm::Expected< std::unique_ptr< InterfaceFile > > merge (const InterfaceFile *O) const
 Merge Interfaces for the same library.
 
void inlineLibrary (std::shared_ptr< InterfaceFile > Library, bool Overwrite=false)
 Inline reexported library into Interface.
 
void setFromBinaryAttrs (const RecordsSlice::BinaryAttrs &BA, const Target &Targ)
 Set InterfaceFile properties from pre-gathered binary attributes, if they are not set already.
 
bool operator== (const InterfaceFile &O) const
 The equality is determined by attributes that impact linking compatibilities.
 
bool operator!= (const InterfaceFile &O) const
 

Detailed Description

Defines the interface file.

Definition at line 105 of file InterfaceFile.h.

Member Typedef Documentation

◆ const_filtered_symbol_range

Definition at line 361 of file InterfaceFile.h.

◆ const_filtered_target_iterator

Definition at line 172 of file InterfaceFile.h.

◆ const_filtered_target_range

Definition at line 175 of file InterfaceFile.h.

◆ const_symbol_range

Definition at line 360 of file InterfaceFile.h.

◆ const_target_iterator

Definition at line 168 of file InterfaceFile.h.

◆ const_target_range

Definition at line 169 of file InterfaceFile.h.

Constructor & Destructor Documentation

◆ InterfaceFile() [1/2]

llvm::MachO::InterfaceFile::InterfaceFile ( std::unique_ptr< SymbolSet > &&  InputSymbols)
inline

Definition at line 107 of file InterfaceFile.h.

◆ InterfaceFile() [2/2]

llvm::MachO::InterfaceFile::InterfaceFile ( )
inline

Definition at line 110 of file InterfaceFile.h.

Referenced by extract(), merge(), and remove().

Member Function Documentation

◆ addAllowableClient()

void InterfaceFile::addAllowableClient ( StringRef  InstallName,
const Target Target 
)

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.

Parameters
InstallNameThe name of the client that is allowed to link this library.
TargetThe target triple for which this applies.

Definition at line 26 of file InterfaceFile.cpp.

References llvm::MachO::addEntry(), and llvm::StringRef::empty().

Referenced by setFromBinaryAttrs().

◆ addDocument()

void InterfaceFile::addDocument ( std::shared_ptr< InterfaceFile > &&  Document)

Add a library for inlining to top level library.

Parameters
DocumentThe library to inline with top level library.

Definition at line 84 of file InterfaceFile.cpp.

References assert(), LHS, llvm::lower_bound(), and RHS.

◆ addParentUmbrella()

void InterfaceFile::addParentUmbrella ( const Target Target_,
StringRef  Parent 
)

Set the parent umbrella frameworks.

Parameters
Target_The target applicable to Parent
ParentThe name of Parent

Definition at line 42 of file InterfaceFile.cpp.

References llvm::StringRef::empty(), LHS, llvm::lower_bound(), and RHS.

Referenced by setFromBinaryAttrs().

◆ addReexportedLibrary()

void InterfaceFile::addReexportedLibrary ( StringRef  InstallName,
const Target Target 
)

Add a re-exported library.

Parameters
InstallNameThe name of the library to re-export.
TargetThe target triple for which this applies.

Definition at line 34 of file InterfaceFile.cpp.

References llvm::MachO::addEntry(), llvm::StringRef::empty(), and llvm::Lib.

Referenced by setFromBinaryAttrs().

◆ addRPath()

void InterfaceFile::addRPath ( StringRef  RPath,
const Target InputTarget 
)

Set the runpath search paths.

Parameters
RPathThe name of runpath.
InputTargetThe target applicable to runpath search path.

Definition at line 57 of file InterfaceFile.cpp.

References llvm::StringRef::empty(), LHS, llvm::lower_bound(), and RHS.

◆ addSymbol() [1/3]

template<typename RangeT , typename ElT = std::remove_reference_t< decltype(*std::begin(std::declval<RangeT>()))>>
void llvm::MachO::InterfaceFile::addSymbol ( EncodeKind  Kind,
StringRef  Name,
RangeT &&  Targets,
SymbolFlags  Flags = SymbolFlags::None 
)
inline

Add a symbol to the symbols list or extend an existing one.

Definition at line 329 of file InterfaceFile.h.

References Name.

◆ addSymbol() [2/3]

void llvm::MachO::InterfaceFile::addSymbol ( EncodeKind  Kind,
StringRef  Name,
Target Target,
SymbolFlags  Flags = SymbolFlags::None 
)
inline

Add Symbol with single target.

Parameters
KindThe kind of global symbol to record.
NameThe name of the symbol.
TargetThe target the symbol is defined in.
FlagsThe properties the symbol holds.

Definition at line 351 of file InterfaceFile.h.

References Name.

◆ addSymbol() [3/3]

void llvm::MachO::InterfaceFile::addSymbol ( EncodeKind  Kind,
StringRef  Name,
TargetList &&  Targets,
SymbolFlags  Flags = SymbolFlags::None 
)
inline

Add Symbol with multiple targets.

Parameters
KindThe kind of global symbol to record.
NameThe name of the symbol.
TargetsThe list of targets the symbol is defined in.
FlagsThe properties the symbol holds.

Definition at line 340 of file InterfaceFile.h.

References Name.

◆ addTarget()

void InterfaceFile::addTarget ( const Target Target)

Set and add target.

Parameters
Targetthe target to add into.

Definition at line 72 of file InterfaceFile.cpp.

References llvm::MachO::addEntry().

Referenced by addTargets().

◆ addTargets()

template<typename RangeT >
void llvm::MachO::InterfaceFile::addTargets ( RangeT &&  Targets)
inline

Set and add targets.

Add the subset of llvm::triples that is supported by Tapi

Parameters
Targetsthe collection of targets.

Definition at line 163 of file InterfaceFile.h.

References addTarget().

◆ allowableClients()

const std::vector< InterfaceFileRef > & llvm::MachO::InterfaceFile::allowableClients ( ) const
inline

Get the list of allowable clients.

Returns
Returns a list of allowable clients.

Definition at line 269 of file InterfaceFile.h.

Referenced by extract(), merge(), and remove().

◆ documents()

const std::vector< std::shared_ptr< InterfaceFile > > & llvm::MachO::InterfaceFile::documents ( ) const
inline

Get the list of inlined libraries.

Returns
Returns a list of the inlined frameworks.

Definition at line 297 of file InterfaceFile.h.

◆ exports()

const_filtered_symbol_range llvm::MachO::InterfaceFile::exports ( ) const
inline

Definition at line 364 of file InterfaceFile.h.

◆ extract()

Expected< std::unique_ptr< InterfaceFile > > InterfaceFile::extract ( Architecture  Arch) const

◆ getArchitectures()

ArchitectureSet llvm::MachO::InterfaceFile::getArchitectures ( ) const
inline

Get the architectures.

Returns
The applicable architectures.

Definition at line 137 of file InterfaceFile.h.

References llvm::MachO::mapToArchitectureSet().

Referenced by extract(), and remove().

◆ getCompatibilityVersion()

PackedVersion llvm::MachO::InterfaceFile::getCompatibilityVersion ( ) const
inline

Get the compatibility version of the library.

Definition at line 199 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ getCurrentVersion()

PackedVersion llvm::MachO::InterfaceFile::getCurrentVersion ( ) const
inline

Get the current version of the library.

Definition at line 191 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ getFileType()

FileType llvm::MachO::InterfaceFile::getFileType ( ) const
inline

Get the file type.

Returns
The file type.

Definition at line 132 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ getInstallName()

StringRef llvm::MachO::InterfaceFile::getInstallName ( ) const
inline

Get the install name of the library.

Definition at line 185 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ getObjCConstraint()

ObjCConstraintType llvm::MachO::InterfaceFile::getObjCConstraint ( ) const
inline

Get the Objective-C constraint.

Definition at line 239 of file InterfaceFile.h.

◆ getParent()

InterfaceFile * llvm::MachO::InterfaceFile::getParent ( ) const
inline

Returns the pointer to parent document if exists or nullptr otherwise.

Definition at line 292 of file InterfaceFile.h.

◆ getPath()

StringRef llvm::MachO::InterfaceFile::getPath ( ) const
inline

Get the path from which this file was generated (if applicable).

Returns
The path to the source file or empty.

Definition at line 119 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ getPlatforms()

PlatformSet llvm::MachO::InterfaceFile::getPlatforms ( ) const
inline

Get the platforms.

Returns
The applicable platforms.

Definition at line 144 of file InterfaceFile.h.

References llvm::MachO::mapToPlatformSet().

◆ getSwiftABIVersion()

uint8_t llvm::MachO::InterfaceFile::getSwiftABIVersion ( ) const
inline

Get the Swift ABI version of the library.

Definition at line 205 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ getSymbol()

std::optional< const Symbol * > llvm::MachO::InterfaceFile::getSymbol ( EncodeKind  Kind,
StringRef  Name,
ObjCIFSymbolKind  ObjCIF = ObjCIFSymbolKind::None 
) const
inline

Get symbol if exists in file.

Parameters
KindThe kind of global symbol to record.
NameThe name of the symbol.
ObjCIFThe ObjCInterface symbol type, if applicable.

Definition at line 319 of file InterfaceFile.h.

References Name, and Sym.

◆ hasSimulatorSupport()

bool llvm::MachO::InterfaceFile::hasSimulatorSupport ( ) const
inline

Check if the library has simulator support.

Definition at line 228 of file InterfaceFile.h.

◆ hasTarget()

bool llvm::MachO::InterfaceFile::hasTarget ( const Target Targ) const
inline

Determine if target triple slice exists in file.

Parameters
Targthe value to find.

Definition at line 154 of file InterfaceFile.h.

References llvm::is_contained().

◆ inlineLibrary()

void InterfaceFile::inlineLibrary ( std::shared_ptr< InterfaceFile Library,
bool  Overwrite = false 
)

Inline reexported library into Interface.

Parameters
LibraryInterface of reexported library.
OverwriteWhether to overwrite preexisting inlined library.

Definition at line 97 of file InterfaceFile.cpp.

References llvm::lower_bound().

◆ isApplicationExtensionSafe()

bool llvm::MachO::InterfaceFile::isApplicationExtensionSafe ( ) const
inline

Check if the library is application extension safe.

Definition at line 225 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ isOSLibNotForSharedCache()

bool llvm::MachO::InterfaceFile::isOSLibNotForSharedCache ( ) const
inline

Check if the library is an OS library that is not shared cache eligible.

Definition at line 219 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ isTwoLevelNamespace()

bool llvm::MachO::InterfaceFile::isTwoLevelNamespace ( ) const
inline

Check if the library uses two-level namespace.

Definition at line 211 of file InterfaceFile.h.

Referenced by extract(), merge(), remove(), and setFromBinaryAttrs().

◆ merge()

Expected< std::unique_ptr< InterfaceFile > > InterfaceFile::merge ( const InterfaceFile O) const

Merge Interfaces for the same library.

The following library attributes must match.

  • Install name, Current & Compatibility version,
  • Two-level namespace enablement, and App extension enablement.
Parameters
OThe Interface to merge.
Returns
New Interface File that was merged.

Definition at line 127 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().

◆ operator!=()

bool llvm::MachO::InterfaceFile::operator!= ( const InterfaceFile O) const
inline

Definition at line 417 of file InterfaceFile.h.

◆ operator==()

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 395 of file InterfaceFile.cpp.

References isYAMLTextStub(), LHS, llvm::MachO::mapToPlatformVersionSet(), and RHS.

◆ reexportedLibraries()

const std::vector< InterfaceFileRef > & llvm::MachO::InterfaceFile::reexportedLibraries ( ) const
inline

Get the list of re-exported libraries.

Returns
Returns a list of re-exported libraries.

Definition at line 282 of file InterfaceFile.h.

Referenced by extract(), merge(), and remove().

◆ reexports()

const_filtered_symbol_range llvm::MachO::InterfaceFile::reexports ( ) const
inline

Definition at line 365 of file InterfaceFile.h.

◆ remove()

Expected< std::unique_ptr< InterfaceFile > > InterfaceFile::remove ( Architecture  Arch) const

◆ rpaths()

const std::vector< std::pair< Target, std::string > > & llvm::MachO::InterfaceFile::rpaths ( ) const
inline

Get the list of runpath search paths.

Returns
Returns a list of the rpaths per target.

Definition at line 309 of file InterfaceFile.h.

Referenced by extract(), and merge().

◆ setApplicationExtensionSafe()

void llvm::MachO::InterfaceFile::setApplicationExtensionSafe ( bool  V = true)
inline

Specify if the library is application extension safe (or not).

Definition at line 222 of file InterfaceFile.h.

Referenced by setFromBinaryAttrs().

◆ setCompatibilityVersion()

void llvm::MachO::InterfaceFile::setCompatibilityVersion ( PackedVersion  Version)
inline

Set the compatibility version of the library.

Definition at line 194 of file InterfaceFile.h.

References llvm::Version.

Referenced by setFromBinaryAttrs().

◆ setCurrentVersion()

void llvm::MachO::InterfaceFile::setCurrentVersion ( PackedVersion  Version)
inline

Set the current version of the library.

Definition at line 188 of file InterfaceFile.h.

References llvm::Version.

Referenced by setFromBinaryAttrs().

◆ setFileType()

void llvm::MachO::InterfaceFile::setFileType ( FileType  Kind)
inline

Set the file type.

This is used by the YAML writer to identify the specification it should use for writing the file.

Parameters
KindThe file type.

Definition at line 127 of file InterfaceFile.h.

Referenced by setFromBinaryAttrs().

◆ setFromBinaryAttrs()

void InterfaceFile::setFromBinaryAttrs ( const RecordsSlice::BinaryAttrs BA,
const Target Targ 
)

◆ setInstallName()

void llvm::MachO::InterfaceFile::setInstallName ( StringRef  InstallName_)
inline

Set the install name of the library.

Definition at line 180 of file InterfaceFile.h.

Referenced by setFromBinaryAttrs().

◆ setObjCConstraint()

void llvm::MachO::InterfaceFile::setObjCConstraint ( ObjCConstraintType  Constraint)
inline

Set the Objective-C constraint.

Definition at line 234 of file InterfaceFile.h.

◆ setOSLibNotForSharedCache()

void llvm::MachO::InterfaceFile::setOSLibNotForSharedCache ( bool  V = true)
inline

Specify if the library is an OS library but not shared cache eligible.

Definition at line 214 of file InterfaceFile.h.

Referenced by setFromBinaryAttrs().

◆ setPath()

void llvm::MachO::InterfaceFile::setPath ( StringRef  Path_)
inline

Set the path from which this file was generated (if applicable).

Parameters
Path_The path to the source file.

Definition at line 114 of file InterfaceFile.h.

Referenced by setFromBinaryAttrs().

◆ setSimulatorSupport()

void llvm::MachO::InterfaceFile::setSimulatorSupport ( bool  V = true)
inline

Specify if the library has simulator support.

Definition at line 231 of file InterfaceFile.h.

◆ setSwiftABIVersion()

void llvm::MachO::InterfaceFile::setSwiftABIVersion ( uint8_t  Version)
inline

Set the Swift ABI version of the library.

Definition at line 202 of file InterfaceFile.h.

References llvm::Version.

Referenced by setFromBinaryAttrs().

◆ setTwoLevelNamespace()

void llvm::MachO::InterfaceFile::setTwoLevelNamespace ( bool  V = true)
inline

Specify if the library uses two-level namespace (or flat namespace).

Definition at line 208 of file InterfaceFile.h.

Referenced by setFromBinaryAttrs().

◆ symbols()

const_symbol_range llvm::MachO::InterfaceFile::symbols ( ) const
inline

Definition at line 363 of file InterfaceFile.h.

Referenced by extract(), merge(), and remove().

◆ symbolsCount()

size_t llvm::MachO::InterfaceFile::symbolsCount ( ) const
inline

Get size of symbol set.

Returns
The number of symbols the file holds.

Definition at line 358 of file InterfaceFile.h.

◆ targets() [1/2]

const_target_range llvm::MachO::InterfaceFile::targets ( ) const
inline

Definition at line 170 of file InterfaceFile.h.

Referenced by extract(), merge(), and remove().

◆ targets() [2/2]

InterfaceFile::const_filtered_target_range InterfaceFile::targets ( ArchitectureSet  Archs) const

◆ umbrellas()

const std::vector< std::pair< Target, std::string > > & llvm::MachO::InterfaceFile::umbrellas ( ) const
inline

Get the list of Parent Umbrella frameworks.

Returns
Returns a list of target information and install name of parent umbrellas.

Definition at line 250 of file InterfaceFile.h.

Referenced by extract(), merge(), and remove().

◆ undefineds()

const_filtered_symbol_range llvm::MachO::InterfaceFile::undefineds ( ) const
inline

Definition at line 368 of file InterfaceFile.h.


The documentation for this class was generated from the following files: