wpiutil: Replace LLVM Optional with C++17-compatible optional

Imported from https://github.com/akrzemi1/Optional with minor changes:
- Compiler conditional simplifications (we only use recent versions)
- Move from std::experimental to wpi namespace
- Change tests to integrate with Google Test

Update LLVM use cases.
This commit is contained in:
Peter Johnson
2018-11-19 22:57:34 -08:00
parent 489701cacc
commit 0b03454366
14 changed files with 2494 additions and 422 deletions

View File

@@ -222,8 +222,8 @@ inline FormattedNumber format_decimal(int64_t N, unsigned Width) {
class FormattedBytes {
ArrayRef<uint8_t> Bytes;
// If not None, display offsets for each line relative to starting value.
Optional<uint64_t> FirstByteOffset;
// If not nullopt, display offsets for each line relative to starting value.
optional<uint64_t> FirstByteOffset;
uint32_t IndentLevel; // Number of characters to indent each line.
uint32_t NumPerLine; // Number of bytes to show per line.
uint8_t ByteGroupSize; // How many hex bytes are grouped without spaces
@@ -232,7 +232,7 @@ class FormattedBytes {
friend class raw_ostream;
public:
FormattedBytes(ArrayRef<uint8_t> B, uint32_t IL, Optional<uint64_t> O,
FormattedBytes(ArrayRef<uint8_t> B, uint32_t IL, optional<uint64_t> O,
uint32_t NPL, uint8_t BGS, bool U, bool A)
: Bytes(B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
ByteGroupSize(BGS), Upper(U), ASCII(A) {
@@ -243,7 +243,7 @@ public:
};
inline FormattedBytes
format_bytes(ArrayRef<uint8_t> Bytes, Optional<uint64_t> FirstByteOffset = None,
format_bytes(ArrayRef<uint8_t> Bytes, optional<uint64_t> FirstByteOffset = nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
uint32_t IndentLevel = 0, bool Upper = false) {
return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
@@ -252,7 +252,7 @@ format_bytes(ArrayRef<uint8_t> Bytes, Optional<uint64_t> FirstByteOffset = None,
inline FormattedBytes
format_bytes_with_ascii(ArrayRef<uint8_t> Bytes,
Optional<uint64_t> FirstByteOffset = None,
optional<uint64_t> FirstByteOffset = nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
uint32_t IndentLevel = 0, bool Upper = false) {
return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,