45#define CV_TYPE(enum, val) {#enum, enum},
46#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
51#define TYPE_RECORD(ename, value, name) \
54#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
66template <
typename T,
typename TFlag>
70 return std::string(
"");
74 for (
const auto &Flag : Flags) {
84 std::string FlagLabel;
86 for (
const auto &Flag : SetFlags) {
92 FlagLabel += (
Flag.Name.str() +
" (0x" + utohexstr(
Flag.Value) +
")");
95 if (!FlagLabel.empty()) {
96 std::string LabelWithBraces(
" ( ");
97 LabelWithBraces += FlagLabel +
" )";
98 return LabelWithBraces;
103template <
typename T,
typename TEnum>
109 for (
const auto &EnumItem : EnumValues) {
110 if (EnumItem.Value ==
Value) {
111 Name = EnumItem.Name;
124 std::string AccessSpecifier = std::string(
126 std::string MemberAttrs(AccessSpecifier);
127 if (Kind != MethodKind::Vanilla) {
132 if (
Options != MethodOptions::None) {
140struct MapOneMethodRecord {
141 explicit MapOneMethodRecord(
bool IsFromOverloadList)
142 : IsFromOverloadList(IsFromOverloadList) {}
145 std::string
Attrs = getMemberAttributes(
148 if (IsFromOverloadList) {
158 if (!IsFromOverloadList)
165 bool IsFromOverloadList;
188 size_t BytesNeeded =
Name.size() + UniqueName.
size() + 2;
189 if (BytesNeeded > BytesLeft) {
196 std::string UniqueB =
Twine(
"??@" + Hash +
"@").
str();
197 assert(UniqueB.size() == 36);
201 const size_t MaxTakeN = 4096;
202 size_t TakeN = std::min(MaxTakeN, BytesLeft - UniqueB.size() - 2) - 32;
204 std::string NameB = (
Name.take_front(TakeN) + Hash).str();
234 assert(!MemberKind &&
"Already in a member mapping!");
239 std::optional<uint32_t> MaxLen;
240 if (CVR.
kind() != TypeLeafKind::LF_FIELDLIST &&
241 CVR.
kind() != TypeLeafKind::LF_METHODLIST)
247 auto RecordKind = CVR.
kind();
249 std::string RecordKindName = std::string(
252 error(IO.
mapEnum(RecordKind,
"Record kind: " + RecordKindName));
260 utohexstr(
Index.getIndex()) +
")");
266 assert(!MemberKind &&
"Still in a member mapping!");
276 assert(!MemberKind &&
"Already in a member mapping!");
302 assert(MemberKind &&
"Not in a member mapping!");
315 std::string ModifierNames =
323Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
325 std::string CallingConvName = std::string(getEnumName(
327 std::string FuncOptionNames =
339Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
341 std::string CallingConvName = std::string(getEnumName(
343 std::string FuncOptionNames =
362 return IO.mapInteger(N,
"Argument");
368Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
373 return IO.mapInteger(N,
"Strings");
385 std::string PtrType = std::string(getEnumName(
387 Attr +=
"[ Type: " + PtrType;
389 std::string PtrMode = std::string(getEnumName(
391 Attr +=
", Mode: " + PtrMode;
393 auto PtrSizeOf =
Record.getSize();
394 Attr +=
", SizeOf: " + itostr(PtrSizeOf);
401 Attr +=
", isVolatile";
403 Attr +=
", isUnaligned";
405 Attr +=
", isRestricted";
406 if (
Record.isLValueReferenceThisPtr())
407 Attr +=
", isThisPtr&";
408 if (
Record.isRValueReferenceThisPtr())
409 Attr +=
", isThisPtr&&";
416 if (
Record.isPointerToMember()) {
418 Record.MemberInfo.emplace();
422 std::string PtrMemberGetRepresentation = std::string(getEnumName(
425 "Representation: " + PtrMemberGetRepresentation));
441 assert((CVR.
kind() == TypeLeafKind::LF_STRUCTURE) ||
442 (CVR.
kind() == TypeLeafKind::LF_CLASS) ||
443 (CVR.
kind() == TypeLeafKind::LF_INTERFACE));
445 std::string PropertiesNames =
461 std::string PropertiesNames =
475 std::string PropertiesNames =
496Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
532 NamesLen +=
Name.size() + 1;
538 return IO.mapStringZ(S,
"MethodName");
552Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
561Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
579Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
588Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
593 return IO.mapInteger(N,
"Argument");
600Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
609Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
620Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
629 std::string ModeName = std::string(
637 std::string
Attrs = getMemberAttributes(
648 std::string
Attrs = getMemberAttributes(
661 std::string
Attrs = getMemberAttributes(
682 const bool IsFromOverloadList = (
TypeKind == LF_METHODLIST);
683 MapOneMethodRecord Mapper(IsFromOverloadList);
684 return Mapper(IO,
Record);
700 std::string
Attrs = getMemberAttributes(
712 std::string
Attrs = getMemberAttributes(
741Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
750Error TypeRecordMapping::visitKnownRecord(
CVType &CVR,
static constexpr uint32_t ContinuationLength
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
static StringRef getLeafTypeName(TypeLeafKind LT)
static const EnumEntry< TypeLeafKind > LeafTypeNames[]
static void computeHashString(StringRef Name, SmallString< 32 > &StringifiedHash)
static Error mapNameAndUniqueName(CodeViewRecordIO &IO, StringRef &Name, StringRef &UniqueName, bool HasUniqueName)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
static void stringifyResult(MD5Result &Result, SmallVectorImpl< char > &Str)
Translates the bytes in Res to a hex string that is deposited into Str.
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
SlotIndex - An opaque wrapper around machine indexes.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
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.
constexpr size_t size() const
size - Get the string size.
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
LLVM Value Representation.
Error mapVectorTail(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
Error mapVectorN(T &Items, const ElementMapper &Mapper, const Twine &Comment="")
Error mapInteger(TypeIndex &TypeInd, const Twine &Comment="")
Error mapGuid(GUID &Guid, const Twine &Comment="")
Error mapStringZ(StringRef &Value, const Twine &Comment="")
Error mapEnum(T &Value, const Twine &Comment="")
Error mapEncodedInteger(int64_t &Value, const Twine &Comment="")
Error beginRecord(std::optional< uint32_t > MaxLength)
Error mapByteVectorTail(ArrayRef< uint8_t > &Bytes, const Twine &Comment="")
uint32_t maxFieldLength() const
void emitRawComment(const Twine &T)
LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records together.
bool isIntroducingVirtual() const
MemberAccess getAccess() const
MethodOptions getOptions() const
MethodKind getMethodKind() const
For method overload sets. LF_METHOD.
StringRef PrecompFilePath
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Error visitMemberBegin(CVMemberRecord &Record) override
Error visitTypeEnd(CVType &Record) override
Error visitMemberEnd(CVMemberRecord &Record) override
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
ArrayRef< EnumEntry< uint16_t > > getMethodOptionNames()
MethodKind
Part of member attribute flags. (CV_methodprop_e)
ArrayRef< EnumEntry< uint8_t > > getCallingConventions()
ArrayRef< EnumEntry< uint8_t > > getMemberAccessNames()
ArrayRef< EnumEntry< uint8_t > > getPtrKindNames()
ArrayRef< EnumEntry< uint16_t > > getPtrMemberRepNames()
ArrayRef< EnumEntry< uint16_t > > getLabelTypeEnum()
Error visitMemberRecordStream(ArrayRef< uint8_t > FieldList, TypeVisitorCallbacks &Callbacks)
ArrayRef< EnumEntry< uint16_t > > getTypeModifierNames()
MethodOptions
Equivalent to CV_fldattr_t bitfield.
ArrayRef< EnumEntry< uint16_t > > getMemberKindNames()
MemberAccess
Source-level access specifier. (CV_access_e)
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
ArrayRef< EnumEntry< uint8_t > > getPtrModeNames()
ArrayRef< EnumEntry< uint8_t > > getFunctionOptionEnum()
ArrayRef< EnumEntry< uint16_t > > getClassOptionNames()
This is an optimization pass for GlobalISel generic memory operations.
void sort(IteratorTy Start, IteratorTy End)