Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:39

0001 //===- Formatters.h ---------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
0011 
0012 #include "llvm/ADT/ArrayRef.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/DebugInfo/CodeView/GUID.h"
0015 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
0016 #include "llvm/Support/FormatAdapters.h"
0017 #include "llvm/Support/FormatVariadic.h"
0018 #include "llvm/Support/raw_ostream.h"
0019 #include <cstdint>
0020 
0021 namespace llvm {
0022 
0023 namespace codeview {
0024 
0025 struct GUID;
0026 
0027 namespace detail {
0028 
0029 class GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> {
0030   ArrayRef<uint8_t> Guid;
0031 
0032 public:
0033   explicit GuidAdapter(ArrayRef<uint8_t> Guid);
0034   explicit GuidAdapter(StringRef Guid);
0035 
0036   void format(raw_ostream &Stream, StringRef Style) override;
0037 };
0038 
0039 } // end namespace detail
0040 
0041 inline detail::GuidAdapter fmt_guid(StringRef Item) {
0042   return detail::GuidAdapter(Item);
0043 }
0044 
0045 inline detail::GuidAdapter fmt_guid(ArrayRef<uint8_t> Item) {
0046   return detail::GuidAdapter(Item);
0047 }
0048 
0049 } // end namespace codeview
0050 
0051 template <> struct format_provider<codeview::TypeIndex> {
0052 public:
0053   static void format(const codeview::TypeIndex &V, raw_ostream &Stream,
0054                      StringRef Style) {
0055     if (V.isNoneType())
0056       Stream << "<no type>";
0057     else {
0058       Stream << formatv("{0:X+4}", V.getIndex());
0059       if (V.isSimple())
0060         Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")";
0061     }
0062   }
0063 };
0064 
0065 template <> struct format_provider<codeview::GUID> {
0066   static void format(const codeview::GUID &V, llvm::raw_ostream &Stream,
0067                      StringRef Style) {
0068     Stream << V;
0069   }
0070 };
0071 
0072 } // end namespace llvm
0073 
0074 #endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H