2017-02-03 22:22:27 +01:00
|
|
|
//===- Formatters.h ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-02-03 22:22:27 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
|
|
|
|
#define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-07-18 01:59:44 +02:00
|
|
|
#include "llvm/DebugInfo/CodeView/GUID.h"
|
2017-06-16 00:24:24 +02:00
|
|
|
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
|
2017-02-03 22:22:27 +01:00
|
|
|
#include "llvm/Support/FormatAdapters.h"
|
2017-06-16 00:24:24 +02:00
|
|
|
#include "llvm/Support/FormatVariadic.h"
|
2017-07-01 01:06:03 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <cstdint>
|
2017-02-03 22:22:27 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
2017-07-01 01:06:03 +02:00
|
|
|
|
2017-02-03 22:22:27 +01:00
|
|
|
namespace codeview {
|
2017-07-01 01:06:03 +02:00
|
|
|
|
2017-02-03 22:22:27 +01:00
|
|
|
namespace detail {
|
2017-07-01 01:06:03 +02:00
|
|
|
|
|
|
|
class GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> {
|
2017-02-03 22:22:27 +01:00
|
|
|
ArrayRef<uint8_t> Guid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit GuidAdapter(ArrayRef<uint8_t> Guid);
|
|
|
|
explicit GuidAdapter(StringRef Guid);
|
2017-07-01 01:06:03 +02:00
|
|
|
|
2017-07-18 01:59:44 +02:00
|
|
|
void format(raw_ostream &Stream, StringRef Style) override;
|
2017-02-03 22:22:27 +01:00
|
|
|
};
|
2017-07-01 01:06:03 +02:00
|
|
|
|
|
|
|
} // end namespace detail
|
2017-02-03 22:22:27 +01:00
|
|
|
|
|
|
|
inline detail::GuidAdapter fmt_guid(StringRef Item) {
|
|
|
|
return detail::GuidAdapter(Item);
|
|
|
|
}
|
2017-03-16 21:18:41 +01:00
|
|
|
|
|
|
|
inline detail::GuidAdapter fmt_guid(ArrayRef<uint8_t> Item) {
|
|
|
|
return detail::GuidAdapter(Item);
|
|
|
|
}
|
2017-07-01 01:06:03 +02:00
|
|
|
|
|
|
|
} // end namespace codeview
|
2017-06-16 00:24:24 +02:00
|
|
|
|
|
|
|
template <> struct format_provider<codeview::TypeIndex> {
|
|
|
|
public:
|
2017-07-01 01:06:03 +02:00
|
|
|
static void format(const codeview::TypeIndex &V, raw_ostream &Stream,
|
2017-06-16 00:24:24 +02:00
|
|
|
StringRef Style) {
|
|
|
|
if (V.isNoneType())
|
|
|
|
Stream << "<no type>";
|
|
|
|
else {
|
|
|
|
Stream << formatv("{0:X+4}", V.getIndex());
|
|
|
|
if (V.isSimple())
|
|
|
|
Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-02-03 22:22:27 +01:00
|
|
|
|
2017-07-18 01:59:44 +02:00
|
|
|
template <> struct format_provider<codeview::GUID> {
|
|
|
|
static void format(const codeview::GUID &V, llvm::raw_ostream &Stream,
|
|
|
|
StringRef Style) {
|
|
|
|
Stream << V;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-01 01:06:03 +02:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
|