9#ifndef LLVM_SUPPORT_SCOPEDPRINTER_H 
   10#define LLVM_SUPPORT_SCOPEDPRINTER_H 
   60  template <
typename EnumT, 
typename = std::enable_if_t<std::is_enum_v<EnumT>>>
 
 
   85  template <
typename EnumT, 
typename = std::enable_if_t<std::is_enum_v<EnumT>>>
 
 
  102template <
typename T, 
typename TEnum>
 
  105    if (EnumItem.Value == 
Value)
 
  106      return std::string(EnumItem.AltName);
 
 
  113template <
typename T, 
typename TEnum>
 
  116    if (EnumItem.Value == 
Value)
 
  117      return EnumItem.AltName;
 
 
  130      : OS(OS), Kind(Kind) {}
 
 
  142  void indent(
int Levels = 1) { IndentLevel += Levels; }
 
  145    IndentLevel = IndentLevel > Levels ? IndentLevel - Levels : 0;
 
 
  156    for (
int i = 0; i < IndentLevel; ++i)
 
 
  162  template <
typename T, 
typename TEnum>
 
  167    for (
const auto &EnumItem : EnumValues) {
 
  168      if (EnumItem.Value == 
Value) {
 
  169        Name = EnumItem.Name;
 
 
  181  template <
typename T, 
typename TFlag>
 
  183                  TFlag EnumMask1 = {}, TFlag EnumMask2 = {},
 
  184                  TFlag EnumMask3 = {}, ArrayRef<FlagEntry> ExtraFlags = {}) {
 
  185    SmallVector<FlagEntry, 10> SetFlags(ExtraFlags);
 
  187    for (
const auto &Flag : Flags) {
 
  188      if (
Flag.Value == TFlag{})
 
  192      if ((
Flag.Value & EnumMask1) != TFlag{})
 
  193        EnumMask = EnumMask1;
 
  194      else if ((
Flag.Value & EnumMask2) != TFlag{})
 
  195        EnumMask = EnumMask2;
 
  196      else if ((
Flag.Value & EnumMask3) != TFlag{})
 
  197        EnumMask = EnumMask3;
 
  198      bool IsEnum = (
Flag.Value & EnumMask) != TFlag{};
 
  200          (IsEnum && (
Value & EnumMask) == 
Flag.Value)) {
 
  201        SetFlags.emplace_back(
Flag.Name, 
Flag.Value);
 
  206    printFlagsImpl(Label, hex(
Value), SetFlags);
 
 
  219    printFlagsImpl(Label, 
hex(
Value), SetFlags);
 
 
  231    startLine() << Label << 
": " << 
static_cast<unsigned>(
Value) << 
"\n";
 
 
  278  template <
typename T>
 
  287  template <
typename T, 
typename... TArgs>
 
  291    ((
getOStream() << 
'.' << MinorVersions), ...);
 
 
  295  template <
typename T>
 
  298    for (
const auto &Item : 
List)
 
 
  304    printListImpl(Label, 
List);
 
 
  308    printListImpl(Label, 
List);
 
 
  312    printListImpl(Label, 
List);
 
 
  316    printListImpl(Label, 
List);
 
 
  320    printListImpl(Label, 
List);
 
 
  327    printListImpl(Label, NumberList);
 
 
  331    printListImpl(Label, 
List);
 
 
  335    printListImpl(Label, 
List);
 
 
  339    printListImpl(Label, 
List);
 
 
  344    for (
const int8_t &Item : 
List)
 
  346    printListImpl(Label, NumberList);
 
 
  350    printListImpl(Label, 
List);
 
 
  353  template <
typename T, 
typename U>
 
  357    for (
const auto &Item : 
List) {
 
 
  366    for (
const auto &Item : 
List)
 
  368    printHexListImpl(Label, HexList);
 
 
  376    printHexImpl(Label, Str, 
hex(
Value));
 
 
  379  template <
typename T>
 
  381    printSymbolOffsetImpl(Label, Symbol, 
hex(
Value));
 
 
  391    printStringEscapedImpl(Label, 
Value);
 
 
  395    printBinaryImpl(Label, Str, 
Value, 
false);
 
 
  401    printBinaryImpl(Label, Str, V, 
false);
 
 
  411    printBinaryImpl(Label, 
StringRef(), V, 
false);
 
 
  417    printBinaryImpl(Label, 
StringRef(), V, 
false);
 
 
  432    printBinaryImpl(Label, 
StringRef(), V, 
true);
 
 
  460    return LHS.Name < 
RHS.Name;
 
  463  virtual void printBinaryImpl(StringRef Label, StringRef Str,
 
  464                               ArrayRef<uint8_t> Value, 
bool Block,
 
  467  virtual void printFlagsImpl(StringRef Label, HexNumber Value,
 
  468                              ArrayRef<FlagEntry> Flags) {
 
  469    startLine() << Label << 
" [ (" << Value << 
")\n";
 
  470    for (
const auto &Flag : Flags)
 
  471      startLine() << 
"  " << Flag.Name << 
" (" << hex(Flag.Value) << 
")\n";
 
  472    startLine() << 
"]\n";
 
  475  virtual void printFlagsImpl(StringRef Label, HexNumber 
Value,
 
  476                              ArrayRef<HexNumber> Flags) {
 
  477    startLine() << 
Label << 
" [ (" << 
Value << 
")\n";
 
  478    for (
const auto &Flag : Flags)
 
  479      startLine() << 
"  " << 
Flag << 
'\n';
 
  480    startLine() << 
"]\n";
 
  483  template <
typename T> 
void printListImpl(StringRef Label, 
const T List) {
 
  484    startLine() << 
Label << 
": [";
 
  486    for (
const auto &Item : List)
 
  491  virtual void printHexListImpl(StringRef Label,
 
  492                                const ArrayRef<HexNumber> List) {
 
  493    startLine() << 
Label << 
": [";
 
  495    for (
const auto &Item : List)
 
  496      OS << 
LS << hex(Item);
 
  500  virtual void printHexImpl(StringRef Label, HexNumber 
Value) {
 
  501    startLine() << 
Label << 
": " << 
Value << 
"\n";
 
  504  virtual void printHexImpl(StringRef Label, StringRef Str, HexNumber 
Value) {
 
  505    startLine() << 
Label << 
": " << Str << 
" (" << 
Value << 
")\n";
 
  508  virtual void printSymbolOffsetImpl(StringRef Label, StringRef Symbol,
 
  513  virtual void printNumberImpl(StringRef Label, StringRef Str,
 
  515    startLine() << 
Label << 
": " << Str << 
" (" << 
Value << 
")\n";
 
  518  virtual void printStringEscapedImpl(StringRef Label, StringRef 
Value) {
 
  519    startLine() << 
Label << 
": ";
 
  520    OS.write_escaped(
Value);
 
  524  void scopedBegin(
char Symbol) {
 
  525    startLine() << 
Symbol << 
'\n';
 
  529  void scopedBegin(StringRef Label, 
char Symbol) {
 
  530    startLine() << 
Label;
 
  537  void scopedEnd(
char Symbol) {
 
  539    startLine() << 
Symbol << 
'\n';
 
  545  ScopedPrinterKind 
Kind;
 
 
  552  startLine() << Label << 
": " << hex(
Value) << 
"\n";
 
 
  570  enum class ScopeKind {
 
  576  struct ScopeContext {
 
  579    ScopeContext(Scope Context, ScopeKind Kind = ScopeKind::NoAttribute)
 
  580        : 
Context(Context), Kind(Kind) {}
 
  585  std::unique_ptr<DelimitedScope> OuterScope;
 
  589                             std::unique_ptr<DelimitedScope> &&OuterScope =
 
  590                                 std::unique_ptr<DelimitedScope>{});
 
  597    JOS.attribute(Label, 
Value);
 
 
  601    JOS.attribute(Label, 
Value);
 
 
  605    JOS.attribute(Label, 
Value);
 
 
  609    JOS.attribute(Label, 
Value);
 
 
  613    JOS.attribute(Label, 
Value);
 
 
  617    JOS.attribute(Label, 
Value);
 
 
  621    JOS.attribute(Label, 
Value);
 
 
  625    JOS.attribute(Label, 
Value);
 
 
  629    JOS.attribute(Label, 
Value);
 
 
  633    JOS.attribute(Label, 
Value);
 
 
  637    JOS.attribute(Label, 
Value);
 
 
  641    JOS.attribute(Label, 
Value);
 
 
  645    JOS.attribute(Label, 
Value);
 
 
  649    JOS.attributeBegin(Label);
 
 
  655    JOS.attribute(Label, 
Value);
 
 
  659    printListImpl(Label, 
List);
 
 
  663    printListImpl(Label, 
List);
 
 
  667    printListImpl(Label, 
List);
 
 
  671    printListImpl(Label, 
List);
 
 
  675    printListImpl(Label, 
List);
 
 
  679    printListImpl(Label, 
List);
 
 
  683    printListImpl(Label, 
List);
 
 
  687    printListImpl(Label, 
List);
 
 
  691    printListImpl(Label, 
List);
 
 
  695    printListImpl(Label, 
List);
 
 
  699    JOS.attributeArray(Label, [&]() {
 
 
  709    JOS.attribute(Label, 
Value);
 
 
  713    scopedBegin({Scope::Object, ScopeKind::NoAttribute});
 
 
  717    scopedBegin(Label, Scope::Object);
 
 
  723    scopedBegin({Scope::Array, ScopeKind::NoAttribute});
 
 
  727    scopedBegin(Label, Scope::Array);
 
 
  736  void printAPSInt(
const APSInt &Value) {
 
  741  void printFlagsImpl(StringRef Label, HexNumber 
Value,
 
  743    JOS.attributeObject(Label, [&]() {
 
  744      JOS.attribute(
"Value", hexNumberToInt(
Value));
 
  745      JOS.attributeArray(
"Flags", [&]() {
 
  746        for (
const FlagEntry &Flag : Flags) {
 
  748          JOS.attribute(
"Name", 
Flag.Name);
 
  749          JOS.attribute(
"Value", 
Flag.Value);
 
  756  void printFlagsImpl(StringRef Label, HexNumber 
Value,
 
  758    JOS.attributeObject(Label, [&]() {
 
  759      JOS.attribute(
"Value", hexNumberToInt(
Value));
 
  760      JOS.attributeArray(
"Flags", [&]() {
 
  761        for (
const HexNumber &Flag : Flags) {
 
  762          JOS.value(
Flag.Value);
 
  768  template <
typename T> 
void printListImpl(StringRef Label, 
const T &
List) {
 
  769    JOS.attributeArray(Label, [&]() {
 
  770      for (
const auto &Item : 
List)
 
  775  void printHexListImpl(StringRef Label,
 
  777    JOS.attributeArray(Label, [&]() {
 
  778      for (
const HexNumber &Item : 
List) {
 
  779        JOS.value(hexNumberToInt(Item));
 
  784  void printHexImpl(StringRef Label, HexNumber 
Value)
 override {
 
  785    JOS.attribute(Label, hexNumberToInt(
Value));
 
  788  void printHexImpl(StringRef Label, StringRef Str, HexNumber 
Value)
 override {
 
  789    JOS.attributeObject(Label, [&]() {
 
  790      JOS.attribute(
"Name", Str);
 
  791      JOS.attribute(
"Value", hexNumberToInt(
Value));
 
  795  void printSymbolOffsetImpl(StringRef Label, StringRef Symbol,
 
  796                             HexNumber 
Value)
 override {
 
  797    JOS.attributeObject(Label, [&]() {
 
  798      JOS.attribute(
"SymName", Symbol);
 
  799      JOS.attribute(
"Offset", hexNumberToInt(
Value));
 
  803  void printNumberImpl(StringRef Label, StringRef Str,
 
  804                       StringRef 
Value)
 override {
 
  805    JOS.attributeObject(Label, [&]() {
 
  806      JOS.attribute(
"Name", Str);
 
  807      JOS.attributeBegin(
"Value");
 
  808      JOS.rawValueBegin() << 
Value;
 
  814  void printBinaryImpl(StringRef Label, StringRef Str, ArrayRef<uint8_t> 
Value,
 
  815                       bool Block, uint32_t StartOffset = 0)
 override {
 
  816    JOS.attributeObject(Label, [&]() {
 
  818        JOS.attribute(
"Value", Str);
 
  819      JOS.attribute(
"Offset", StartOffset);
 
  820      JOS.attributeArray(
"Bytes", [&]() {
 
  821        for (uint8_t Val : 
Value)
 
  827  void scopedBegin(ScopeContext ScopeCtx) {
 
  828    if (ScopeCtx.Context == Scope::Object)
 
  830    else if (ScopeCtx.Context == Scope::Array)
 
  832    ScopeHistory.push_back(ScopeCtx);
 
  835  void scopedBegin(StringRef Label, Scope Ctx) {
 
  836    ScopeKind Kind = ScopeKind::Attribute;
 
  837    if (ScopeHistory.empty() || ScopeHistory.back().Context != Scope::Object) {
 
  839      Kind = ScopeKind::NestedAttribute;
 
  841    JOS.attributeBegin(Label);
 
  842    scopedBegin({Ctx, Kind});
 
  846    ScopeContext ScopeCtx = ScopeHistory.back();
 
  847    if (ScopeCtx.Context == Scope::Object)
 
  849    else if (ScopeCtx.Context == Scope::Array)
 
  851    if (ScopeCtx.Kind == ScopeKind::Attribute ||
 
  852        ScopeCtx.Kind == ScopeKind::NestedAttribute)
 
  854    if (ScopeCtx.Kind == ScopeKind::NestedAttribute)
 
  856    ScopeHistory.pop_back();
 
 
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
 
static constexpr std::size_t number(BlockVerifier::State S)
 
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
 
dxil pretty DXIL Metadata Pretty Printer
 
This file supports working with JSON data.
 
This file contains library features backported from future STL versions.
 
This file defines the SmallVector class.
 
An arbitrary precision integer that knows its signedness.
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
void printNumber(StringRef Label, signed char Value) override
 
void printNumber(StringRef Label, double Value) override
 
void printList(StringRef Label, const ArrayRef< std::string > List) override
 
void printNumber(StringRef Label, float Value) override
 
void printNumber(StringRef Label, short Value) override
 
void printNumber(StringRef Label, long long Value) override
 
void printList(StringRef Label, const ArrayRef< uint8_t > List) override
 
void printList(StringRef Label, const ArrayRef< int32_t > List) override
 
void printNumber(StringRef Label, char Value) override
 
void printBoolean(StringRef Label, bool Value) override
 
void printNumber(StringRef Label, unsigned char Value) override
 
void printList(StringRef Label, const ArrayRef< int64_t > List) override
 
void printNumber(StringRef Label, int Value) override
 
LLVM_ABI JSONScopedPrinter(raw_ostream &OS, bool PrettyPrint=false, std::unique_ptr< DelimitedScope > &&OuterScope=std::unique_ptr< DelimitedScope >{})
 
void printList(StringRef Label, const ArrayRef< bool > List) override
 
void arrayBegin() override
 
void printList(StringRef Label, const ArrayRef< APSInt > List) override
 
void printList(StringRef Label, const ArrayRef< uint64_t > List) override
 
void printList(StringRef Label, const ArrayRef< uint16_t > List) override
 
void printNumber(StringRef Label, long Value) override
 
void printList(StringRef Label, const ArrayRef< int16_t > List) override
 
void objectEnd() override
 
static bool classof(const ScopedPrinter *SP)
 
void printNumber(StringRef Label, const APSInt &Value) override
 
void printList(StringRef Label, const ArrayRef< uint32_t > List) override
 
void printNumber(StringRef Label, unsigned int Value) override
 
void arrayBegin(StringRef Label) override
 
void printString(StringRef Value) override
 
void printNumber(StringRef Label, unsigned short Value) override
 
void objectBegin(StringRef Label) override
 
void printNumber(StringRef Label, unsigned long Value) override
 
void printString(StringRef Label, StringRef Value) override
 
void printList(StringRef Label, const ArrayRef< int8_t > List) override
 
void printNumber(StringRef Label, unsigned long long Value) override
 
void objectBegin() override
 
A helper class to return the specified delimiter string after the first invocation of operator String...
 
virtual void printList(StringRef Label, const ArrayRef< int32_t > List)
 
void printHexList(StringRef Label, const T &List)
 
virtual void printList(StringRef Label, const ArrayRef< uint32_t > List)
 
void printBinary(StringRef Label, StringRef Str, ArrayRef< char > Value)
 
virtual void printString(StringRef Value)
 
void printBinaryBlock(StringRef Label, ArrayRef< uint8_t > Value, uint32_t StartOffset)
 
void printStringEscaped(StringRef Label, StringRef Value)
 
void printBinaryBlock(StringRef Label, StringRef Value)
 
virtual void printNumber(StringRef Label, unsigned short Value)
 
virtual void printNumber(StringRef Label, long Value)
 
virtual void printList(StringRef Label, const ArrayRef< int64_t > List)
 
virtual void printNumber(StringRef Label, unsigned int Value)
 
void indent(int Levels=1)
 
virtual void printList(StringRef Label, const ArrayRef< int16_t > List)
 
virtual void printNumber(StringRef Label, long long Value)
 
void printFlags(StringRef Label, T Value)
 
virtual void printList(StringRef Label, const ArrayRef< std::string > List)
 
void unindent(int Levels=1)
 
void printBinaryBlock(StringRef Label, ArrayRef< uint8_t > Value)
 
virtual void arrayBegin(StringRef Label)
 
void printEnum(StringRef Label, T Value, ArrayRef< EnumEntry< TEnum > > EnumValues)
 
virtual void printList(StringRef Label, const ArrayRef< bool > List)
 
virtual void printList(StringRef Label, const ArrayRef< APSInt > List)
 
ScopedPrinterKind getKind() const
 
virtual void printNumber(StringRef Label, const APSInt &Value)
 
ScopedPrinter(raw_ostream &OS, ScopedPrinterKind Kind=ScopedPrinterKind::Base)
 
void printList(StringRef Label, const T &List, const U &Printer)
 
virtual void printNumber(StringRef Label, short Value)
 
void printBinary(StringRef Label, StringRef Value)
 
virtual raw_ostream & getOStream()
 
virtual void printList(StringRef Label, const ArrayRef< int8_t > List)
 
static bool classof(const ScopedPrinter *SP)
 
virtual void printNumber(StringRef Label, unsigned long Value)
 
virtual raw_ostream & startLine()
 
virtual void printNumber(StringRef Label, char Value)
 
virtual void printNumber(StringRef Label, int Value)
 
void printBinary(StringRef Label, StringRef Str, ArrayRef< uint8_t > Value)
 
virtual void printList(StringRef Label, const ArrayRef< uint64_t > List)
 
virtual void printNumber(StringRef Label, float Value)
 
void printHex(StringRef Label, T Value)
 
virtual void objectBegin(StringRef Label)
 
void setPrefix(StringRef P)
 
void printFlags(StringRef Label, T Value, ArrayRef< EnumEntry< TFlag > > Flags, TFlag EnumMask1={}, TFlag EnumMask2={}, TFlag EnumMask3={}, ArrayRef< FlagEntry > ExtraFlags={})
 
void printVersion(StringRef Label, T MajorVersion, TArgs... MinorVersions)
 
virtual ~ScopedPrinter()=default
 
virtual void arrayBegin()
 
virtual void printBoolean(StringRef Label, bool Value)
 
void printHex(StringRef Label, StringRef Str, T Value)
 
void printNumber(StringRef Label, StringRef Str, T Value)
 
virtual void objectBegin()
 
virtual void printNumber(StringRef Label, signed char Value)
 
virtual void printNumber(StringRef Label, unsigned char Value)
 
virtual void printNumber(StringRef Label, unsigned long long Value)
 
virtual void printList(StringRef Label, const ArrayRef< uint16_t > List)
 
virtual void printString(StringRef Label, StringRef Value)
 
virtual void printList(StringRef Label, const ArrayRef< uint8_t > List)
 
void printSymbolOffset(StringRef Label, StringRef Symbol, T Value)
 
virtual void printNumber(StringRef Label, double Value)
 
void printBinary(StringRef Label, ArrayRef< char > Value)
 
void printList(StringRef Label, const ArrayRef< T > List)
 
void printBinary(StringRef Label, ArrayRef< uint8_t > Value)
 
void printObject(StringRef Label, const T &Value)
 
reference emplace_back(ArgTypes &&... Args)
 
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.
 
LLVM Value Representation.
 
json::OStream allows writing well-formed JSON without materializing all structures as json::Value ahe...
 
LLVM_ABI raw_ostream & rawValueBegin()
 
LLVM_ABI void rawValueEnd()
 
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.
 
Flag
These should be considered private to the implementation of the MCInstrDesc class.
 
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
 
This is an optimization pass for GlobalISel generic memory operations.
 
FunctionAddr VTableAddr Value
 
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
 
std::string enumToString(T Value, ArrayRef< EnumEntry< TEnum > > EnumValues)
 
void sort(IteratorTy Start, IteratorTy End)
 
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
 
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
 
const char * to_string(ThinOrFullLTOPhase Phase)
 
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
 
ArrayRef(const T &OneElt) -> ArrayRef< T >
 
StringRef enumToStringRef(T Value, ArrayRef< EnumEntry< TEnum > > EnumValues)
Retrieves the Value's enum name.
 
virtual void setPrinter(ScopedPrinter &W)=0
 
DelimitedScope(ScopedPrinter &W)
 
virtual ~DelimitedScope()=default
 
DictScope(ScopedPrinter &W)
 
DictScope(ScopedPrinter &W, StringRef N)
 
void setPrinter(ScopedPrinter &W) override
 
constexpr EnumEntry(StringRef N, StringRef A, T V)
 
constexpr EnumEntry(StringRef N, T V)
 
FlagEntry(StringRef Name, signed long Value)
 
FlagEntry(StringRef Name, signed int Value)
 
FlagEntry(StringRef Name, unsigned short Value)
 
FlagEntry(StringRef Name, unsigned long long Value)
 
FlagEntry(StringRef Name, unsigned long Value)
 
FlagEntry(StringRef Name, signed long long Value)
 
FlagEntry(StringRef Name, char Value)
 
FlagEntry(StringRef Name, signed char Value)
 
FlagEntry(StringRef Name, signed short Value)
 
FlagEntry(StringRef Name, EnumT Value)
 
FlagEntry(StringRef Name, unsigned int Value)
 
FlagEntry(StringRef Name, unsigned char Value)
 
HexNumber(unsigned char Value)
 
HexNumber(signed int Value)
 
HexNumber(signed long long Value)
 
HexNumber(signed long Value)
 
HexNumber(unsigned int Value)
 
HexNumber(unsigned long long Value)
 
HexNumber(signed char Value)
 
HexNumber(signed short Value)
 
HexNumber(unsigned long Value)
 
HexNumber(unsigned short Value)
 
ListScope(ScopedPrinter &W)
 
void setPrinter(ScopedPrinter &W) override
 
ListScope(ScopedPrinter &W, StringRef N)