LLVM: lib/TextAPI/PackedVersion.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
18
19namespace llvm {
21
23 Version = 0;
24
25 if (Str.empty())
26 return false;
27
30
31 if (Parts.size() > 3 || Parts.empty())
32 return false;
33
34 unsigned long long Num;
36 return false;
37
38 if (Num > UINT16_MAX)
39 return false;
40
41 Version = Num << 16;
42
43 for (unsigned i = 1, ShiftNum = 8; i < Parts.size(); ++i, ShiftNum -= 8) {
45 return false;
46
47 if (Num > UINT8_MAX)
48 return false;
49
50 Version |= (Num << ShiftNum);
51 }
52
53 return true;
54}
55
57 bool Truncated = false;
58 Version = 0;
59
60 if (Str.empty())
61 return std::make_pair(false, Truncated);
62
65
66 if (Parts.size() > 5 || Parts.empty())
67 return std::make_pair(false, Truncated);
68
69 unsigned long long Num;
71 return std::make_pair(false, Truncated);
72
73 if (Num > 0xFFFFFFULL)
74 return std::make_pair(false, Truncated);
75
76 if (Num > 0xFFFFULL) {
77 Num = 0xFFFFULL;
78 Truncated = true;
79 }
80 Version = Num << 16;
81
82 for (unsigned i = 1, ShiftNum = 8; i < Parts.size() && i < 3;
83 ++i, ShiftNum -= 8) {
85 return std::make_pair(false, Truncated);
86
87 if (Num > 0x3FFULL)
88 return std::make_pair(false, Truncated);
89
90 if (Num > 0xFFULL) {
91 Num = 0xFFULL;
92 Truncated = true;
93 }
94 Version |= (Num << ShiftNum);
95 }
96
97 if (Parts.size() > 3)
98 Truncated = true;
99
100 return std::make_pair(true, Truncated);
101}
102
103PackedVersion::operator std::string() const {
107 return std::string(Str);
108}
109
117
118}
119}
This file defines the SmallVector class.
LLVM_ABI void print(raw_ostream &OS) const
Definition PackedVersion.cpp:110
unsigned getMinor() const
Retrieve the minor version number, if provided.
LLVM_ABI bool parse32(StringRef Str)
Definition PackedVersion.cpp:22
LLVM_ABI std::pair< bool, bool > parse64(StringRef Str)
Definition PackedVersion.cpp:56
unsigned getSubminor() const
Retrieve the subminor version number, if provided.
unsigned getMajor() const
Retrieve the major version number.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI void SplitString(StringRef Source, SmallVectorImpl< StringRef > &OutFragments, StringRef Delimiters=" \t\n\v\f\r")
SplitString - Split up the specified string according to the specified delimiters,...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_ABI bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.