1//===- VersionTuple.cpp - Version Number Handling ---------------*- C++ -*-===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//===----------------------------------------------------------------------===//
9// This file implements the VersionTuple class, which represents a version in
10// the form major[.minor[.subminor]].
12//===----------------------------------------------------------------------===//
32 if (std::optional<unsigned> Minor = V.getMinor())
34 if (std::optional<unsigned> Subminor = V.getSubminor())
35 Out <<
'.' << *Subminor;
36 if (std::optional<unsigned> Build = V.getBuild())
48 if (next <
'0' || next >
'9')
52 while (!input.
empty()) {
54 if (next <
'0' || next >
'9')
57 value = value * 10 + (
unsigned)(next -
'0');
64 unsigned major = 0, minor = 0, micro = 0, build = 0;
66 // Parse the major version, [0-9]+
75 // If we're not done, parse the minor version, \.[0-9]+
87 // If we're not done, parse the micro version, \.[0-9]+
98 // If we're not done, parse the micro version, \.[0-9]+
104 // If we have characters left over, it's an error.
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool parseInt(StringRef &input, unsigned &value)
Defines the llvm::VersionTuple class, which represents a version in the form major[....
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Represents a version number in the form major[.minor[.subminor[.build]]].
LLVM_ABI bool tryParse(StringRef string)
Try to parse the given string as a version number.
LLVM_ABI std::string getAsString() const
Retrieve a string representation of the version number.
LLVM_ABI VersionTuple withMajorReplaced(unsigned NewMajor) const
Return a version tuple that contains a different major version but everything else is the same.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)