2017-02-03 22:22:27 +01:00
|
|
|
//===- Formatters.h ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
|
|
|
|
#define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include "llvm/ADT/StringRef.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
|
|
|
|
|
|
|
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-01 01:06:03 +02:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
|