15 #include "llvm/Support/raw_ostream.h"
17 using namespace clang;
22 llvm::raw_string_ostream Out(Result);
40 static bool parseInt(StringRef &input,
unsigned &value) {
42 if (input.empty())
return true;
45 input = input.substr(1);
46 if (next < '0' || next >
'9')
return true;
49 while (!input.empty()) {
51 if (next < '0' || next >
'9')
return false;
52 input = input.substr(1);
53 value = value * 10 + (
unsigned) (next -
'0');
60 unsigned major = 0, minor = 0, micro = 0, build = 0;
63 if (
parseInt(input, major))
return true;
71 if (input[0] !=
'.')
return true;
72 input = input.substr(1);
73 if (
parseInt(input, minor))
return true;
81 if (input[0] !=
'.')
return true;
82 input = input.substr(1);
83 if (
parseInt(input, micro))
return true;
91 if (input[0] !=
'.')
return true;
92 input = input.substr(1);
93 if (
parseInt(input, build))
return true;
96 if (!input.empty())
return true;
Represents a version number in the form major[.minor[.subminor[.build]]].
bool usesUnderscores() const
Optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
std::string getAsString() const
Retrieve a string representation of the version number.
The result type of a method or function.
unsigned getMajor() const
Retrieve the major version number.
static bool parseInt(StringRef &input, unsigned &value)
bool tryParse(StringRef string)
Try to parse the given string as a version number.
Optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
Optional< unsigned > getBuild() const
Retrieve the build version number, if provided.
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].