15 #ifndef LLVM_SUPPORT_FORMATPROVIDERS_H 16 #define LLVM_SUPPORT_FORMATPROVIDERS_H 25 #include <type_traits> 32 :
public std::integral_constant<
33 bool, is_one_of<T, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
34 int64_t, uint64_t, int, unsigned, long, unsigned long,
35 long long, unsigned long long>::value> {};
39 :
public std::integral_constant<bool, std::is_same<T, char>::value> {};
43 :
public std::integral_constant<bool,
44 is_one_of<T, char *, const char *>::value> {
49 :
public std::integral_constant<bool,
50 std::is_convertible<T, llvm::StringRef>::value> {};
54 :
public std::integral_constant<bool, std::is_pointer<T>::value &&
55 !is_cstring<T>::value> {};
59 :
public std::integral_constant<bool, std::is_floating_point<T>::value> {};
69 assert(
false &&
"Invalid precision specifier");
72 assert(Prec < 100 &&
"Precision out of range");
73 Result = std::min<size_t>(99u, Prec);
126 template <
typename T>
128 T, typename
std::enable_if<detail::use_integral_formatter<T>::value>
::type>
135 if (consumeHexStyle(Style, HS)) {
136 Digits = consumeNumHexDigits(Style, HS, 0);
148 assert(Style.
empty() &&
"Invalid integral format style!");
175 template <
typename T>
177 T, typename
std::enable_if<detail::use_pointer_formatter<T>::value>
::type>
183 consumeHexStyle(Style, HS);
184 size_t Digits = consumeNumHexDigits(Style, HS,
sizeof(
void *) * 2);
185 write_hex(Stream, reinterpret_cast<std::uintptr_t>(V), HS, Digits);
200 template <
typename T>
202 T, typename
std::enable_if<detail::use_string_formatter<T>::value>
::type> {
206 assert(
false &&
"Style is not a valid integer");
233 template <
typename T>
235 T, typename
std::enable_if<detail::use_char_formatter<T>::value>
::type> {
241 int X =
static_cast<int>(V);
266 Stream << StringSwitch<const char *>(
Style)
267 .Case(
"Y", B ?
"YES" :
"NO")
268 .Case(
"y", B ?
"yes" :
"no")
269 .CaseLower(
"D", B ?
"1" :
"0")
270 .Case(
"T", B ?
"TRUE" :
"FALSE")
271 .Cases(
"t",
"", B ?
"true" :
"false")
272 .Default(B ?
"1" :
"0");
299 template <
typename T>
301 T, typename
std::enable_if<detail::use_double_formatter<T>::value>
::type>
320 write_double(Stream, static_cast<double>(V), S, Precision);
325 template <
typename IterT>
326 using IterValue =
typename std::iterator_traits<IterT>::value_type;
328 template <
typename IterT>
330 :
public std::integral_constant<
331 bool, !uses_missing_provider<IterValue<IterT>>::value> {};
358 using value =
typename std::iterator_traits<IterT>::value_type;
359 using reference =
typename std::iterator_traits<IterT>::reference;
365 if (Style.
front() != Indicator)
369 assert(
false &&
"Invalid range style");
373 for (
const char *
D : {
"[]",
"<>",
"()"}) {
374 if (Style.
front() !=
D[0])
378 assert(
false &&
"Missing range option end delimeter!");
385 assert(
false &&
"Invalid range style!");
389 static std::pair<StringRef, StringRef> parseOptions(
StringRef Style) {
390 StringRef Sep = consumeOneOption(Style,
'$',
", ");
392 assert(Style.
empty() &&
"Unexpected text in range option string!");
393 return std::make_pair(Sep, Args);
398 "Range value_type does not have a format provider!");
403 std::tie(Sep, ArgStyle) = parseOptions(Style);
404 auto Begin = V.
begin();
409 Adapter.format(Stream, ArgStyle);
412 while (Begin != End) {
416 Adapter.format(Stream, ArgStyle);
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
LLVM_NODISCARD bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
This class represents lattice values for constants.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
static bool consumeHexStyle(StringRef &Str, HexPrintStyle &Style)
void write_double(raw_ostream &S, double D, FloatStyle Style, Optional< size_t > Precision=None)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
size_t getDefaultPrecision(FloatStyle Style)
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
bool isPrefixedHexStyle(HexPrintStyle S)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
A range adaptor for a pair of iterators.
typename std::iterator_traits< IterT >::value_type IterValue
void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, Optional< size_t > Width=None)
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
std::string str() const
Return the twine contents as a std::string.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_NODISCARD char front() const
front - Get the first character in the string.
std::enable_if< uses_format_member< T >::value, T >::type build_format_adapter(T &&Item)
This class implements an extremely fast bulk output stream that can only output to a stream...
static Optional< size_t > parseNumericPrecision(StringRef Str)
StringRef - Represent a constant reference to a string, i.e.
void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, IntegerStyle Style)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
static size_t consumeNumHexDigits(StringRef &Str, HexPrintStyle Style, size_t Default)