LLVM 23.0.0git
llvm::VersionTuple Class Reference

Represents a version number in the form major[.minor[.subminor[.build]]]. More...

#include "llvm/Support/VersionTuple.h"

Public Member Functions

constexpr VersionTuple ()
constexpr VersionTuple (unsigned Major)
constexpr VersionTuple (unsigned Major, unsigned Minor)
constexpr VersionTuple (unsigned Major, unsigned Minor, unsigned Subminor)
constexpr VersionTuple (unsigned Major, unsigned Minor, unsigned Subminor, unsigned Build)
constexpr VersionTuple (unsigned Major, unsigned Minor, unsigned Subminor, unsigned Build, unsigned Subbuild)
std::tuple< unsigned, unsigned, unsigned, unsigned, unsignedasTuple () const
bool empty () const
 Determine whether this version information is empty (e.g., all version components are zero).
unsigned getMajor () const
 Retrieve the major version number.
std::optional< unsignedgetMinor () const
 Retrieve the minor version number, if provided.
std::optional< unsignedgetSubminor () const
 Retrieve the subminor version number, if provided.
std::optional< unsignedgetBuild () const
 Retrieve the build version number, if provided.
std::optional< unsignedgetSubbuild () const
 Retrieve the subbuild version number, if provided.
VersionTuple withoutBuild () const
 Return a version tuple that contains only the first 3 version components.
LLVM_ABI VersionTuple withMajorReplaced (unsigned NewMajor) const
 Return a version tuple that contains a different major version but everything else is the same.
VersionTuple normalize () const
 Return a version tuple that contains only components that are non-zero.
LLVM_ABI std::string getAsString () const
 Retrieve a string representation of the version number.
LLVM_ABI bool tryParse (StringRef string)
 Try to parse the given string as a version number.

Friends

bool operator== (const VersionTuple &X, const VersionTuple &Y)
 Determine if two version numbers are equivalent.
bool operator!= (const VersionTuple &X, const VersionTuple &Y)
 Determine if two version numbers are not equivalent.
bool operator< (const VersionTuple &X, const VersionTuple &Y)
 Determine whether one version number precedes another.
bool operator> (const VersionTuple &X, const VersionTuple &Y)
 Determine whether one version number follows another.
bool operator<= (const VersionTuple &X, const VersionTuple &Y)
 Determine whether one version number precedes or is equivalent to another.
bool operator>= (const VersionTuple &X, const VersionTuple &Y)
 Determine whether one version number follows or is equivalent to another.
hash_code hash_value (const VersionTuple &VT)
template<typename HasherT, llvm::endianness Endianness>
void addHash (HashBuilder< HasherT, Endianness > &HBuilder, const VersionTuple &VT)

Detailed Description

Represents a version number in the form major[.minor[.subminor[.build]]].

Definition at line 30 of file VersionTuple.h.

Constructor & Destructor Documentation

◆ VersionTuple() [1/6]

llvm::VersionTuple::VersionTuple ( )
inlineconstexpr

◆ VersionTuple() [2/6]

llvm::VersionTuple::VersionTuple ( unsigned Major)
inlineexplicitconstexpr

Definition at line 49 of file VersionTuple.h.

◆ VersionTuple() [3/6]

llvm::VersionTuple::VersionTuple ( unsigned Major,
unsigned Minor )
inlineexplicitconstexpr

Definition at line 54 of file VersionTuple.h.

◆ VersionTuple() [4/6]

llvm::VersionTuple::VersionTuple ( unsigned Major,
unsigned Minor,
unsigned Subminor )
inlineexplicitconstexpr

Definition at line 59 of file VersionTuple.h.

◆ VersionTuple() [5/6]

llvm::VersionTuple::VersionTuple ( unsigned Major,
unsigned Minor,
unsigned Subminor,
unsigned Build )
inlineexplicitconstexpr

Definition at line 65 of file VersionTuple.h.

◆ VersionTuple() [6/6]

llvm::VersionTuple::VersionTuple ( unsigned Major,
unsigned Minor,
unsigned Subminor,
unsigned Build,
unsigned Subbuild )
inlineexplicitconstexpr

Definition at line 71 of file VersionTuple.h.

Member Function Documentation

◆ asTuple()

std::tuple< unsigned, unsigned, unsigned, unsigned, unsigned > llvm::VersionTuple::asTuple ( ) const
inline

Definition at line 78 of file VersionTuple.h.

◆ empty()

bool llvm::VersionTuple::empty ( ) const
inline

Determine whether this version information is empty (e.g., all version components are zero).

Definition at line 84 of file VersionTuple.h.

References VersionTuple().

Referenced by EmitSDKVersionSuffix(), emitValidatorVersionMD(), getDXILArchNameFromShaderModel(), llvm::MachO::getTargetTripleName(), getWindowsSDKDirViaCommandLine(), and targetVersionOrMinimumSupportedOSVersion().

◆ getAsString()

std::string VersionTuple::getAsString ( ) const

Retrieve a string representation of the version number.

Definition at line 21 of file VersionTuple.cpp.

Referenced by llvm::MachO::getTargetTripleName(), and getWindowsSDKDirViaCommandLine().

◆ getBuild()

std::optional< unsigned > llvm::VersionTuple::getBuild ( ) const
inline

Retrieve the build version number, if provided.

Definition at line 104 of file VersionTuple.h.

◆ getMajor()

◆ getMinor()

std::optional< unsigned > llvm::VersionTuple::getMinor ( ) const
inline

◆ getSubbuild()

std::optional< unsigned > llvm::VersionTuple::getSubbuild ( ) const
inline

Retrieve the subbuild version number, if provided.

Definition at line 111 of file VersionTuple.h.

◆ getSubminor()

std::optional< unsigned > llvm::VersionTuple::getSubminor ( ) const
inline

Retrieve the subminor version number, if provided.

Definition at line 97 of file VersionTuple.h.

Referenced by EmitSDKVersionSuffix(), and llvm::MachO::PackedVersion::PackedVersion().

◆ normalize()

VersionTuple llvm::VersionTuple::normalize ( ) const
inline

Return a version tuple that contains only components that are non-zero.

Definition at line 129 of file VersionTuple.h.

References VersionTuple().

◆ tryParse()

bool VersionTuple::tryParse ( StringRef string)

Try to parse the given string as a version number.

Returns
true if the string does not match the regular expression [0-9]+(.[0-9]+){0,3}

Definition at line 65 of file VersionTuple.cpp.

References llvm::StringRef::consume_front(), llvm::StringRef::empty(), parseInt(), llvm::StringRef::substr(), and VersionTuple().

Referenced by getWindowsSDKDirViaCommandLine(), and parseVersionFromName().

◆ withMajorReplaced()

VersionTuple VersionTuple::withMajorReplaced ( unsigned NewMajor) const

Return a version tuple that contains a different major version but everything else is the same.

Definition at line 129 of file VersionTuple.cpp.

References VersionTuple().

◆ withoutBuild()

VersionTuple llvm::VersionTuple::withoutBuild ( ) const
inline

Return a version tuple that contains only the first 3 version components.

Definition at line 118 of file VersionTuple.h.

References VersionTuple().

◆ addHash

template<typename HasherT, llvm::endianness Endianness>
void addHash ( HashBuilder< HasherT, Endianness > & HBuilder,
const VersionTuple & VT )
friend

◆ hash_value

hash_code hash_value ( const VersionTuple & VT)
friend

Definition at line 193 of file VersionTuple.h.

References llvm::hash_combine(), and VersionTuple().

◆ operator!=

bool operator!= ( const VersionTuple & X,
const VersionTuple & Y )
friend

Determine if two version numbers are not equivalent.

If not provided, minor and subminor version numbers are considered to be zero.

Definition at line 155 of file VersionTuple.h.

References VersionTuple(), X, and Y.

◆ operator<

bool operator< ( const VersionTuple & X,
const VersionTuple & Y )
friend

Determine whether one version number precedes another.

If not provided, minor and subminor version numbers are considered to be zero.

Definition at line 163 of file VersionTuple.h.

References VersionTuple(), X, and Y.

◆ operator<=

bool operator<= ( const VersionTuple & X,
const VersionTuple & Y )
friend

Determine whether one version number precedes or is equivalent to another.

If not provided, minor and subminor version numbers are considered to be zero.

Definition at line 180 of file VersionTuple.h.

References VersionTuple(), X, and Y.

◆ operator==

bool operator== ( const VersionTuple & X,
const VersionTuple & Y )
friend

Determine if two version numbers are equivalent.

If not provided, minor and subminor version numbers are considered to be zero.

Definition at line 147 of file VersionTuple.h.

References VersionTuple(), X, and Y.

◆ operator>

bool operator> ( const VersionTuple & X,
const VersionTuple & Y )
friend

Determine whether one version number follows another.

If not provided, minor and subminor version numbers are considered to be zero.

Definition at line 171 of file VersionTuple.h.

References VersionTuple(), X, and Y.

◆ operator>=

bool operator>= ( const VersionTuple & X,
const VersionTuple & Y )
friend

Determine whether one version number follows or is equivalent to another.

If not provided, minor and subminor version numbers are considered to be zero.

Definition at line 189 of file VersionTuple.h.

References VersionTuple(), X, and Y.


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