23 #define CV_TYPE(enum, val) {#enum, enum}, 24 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" 29 #define TYPE_RECORD(ename, value, name) \ 32 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" 44 template <
typename T,
typename TFlag>
48 return std::string(
"");
52 for (
const auto &
Flag : Flags) {
55 if ((Value &
Flag.Value) ==
Flag.Value) {
62 std::string FlagLabel;
64 for (
const auto &
Flag : SetFlags) {
73 if (!FlagLabel.empty()) {
74 std::string LabelWithBraces(
" ( ");
75 LabelWithBraces += FlagLabel +
" )";
76 return LabelWithBraces;
81 template <
typename T,
typename TEnum>
87 for (
const auto &EnumItem : EnumValues) {
88 if (EnumItem.Value == Value) {
102 std::string AccessSpecifier =
104 std::string MemberAttrs(AccessSpecifier);
118 struct MapOneMethodRecord {
119 explicit MapOneMethodRecord(
bool IsFromOverloadList)
120 : IsFromOverloadList(IsFromOverloadList) {}
123 std::string
Attrs = getMemberAttributes(
126 if (IsFromOverloadList) {
136 if (!IsFromOverloadList)
143 bool IsFromOverloadList;
155 size_t BytesNeeded = Name.
size() + UniqueName.
size() + 2;
158 if (BytesNeeded > BytesLeft) {
159 size_t BytesToDrop = (BytesNeeded - BytesLeft);
160 size_t DropN = std::min(N.
size(), BytesToDrop / 2);
161 size_t DropU = std::min(U.
size(), BytesToDrop - DropN);
189 assert(!MemberKind.hasValue() &&
"Already in a member mapping!");
195 if (CVR.
kind() != TypeLeafKind::LF_FIELDLIST &&
196 CVR.
kind() != TypeLeafKind::LF_METHODLIST)
198 error(IO.beginRecord(MaxLen));
201 if (IO.isStreaming()) {
202 auto RecordKind = CVR.
kind();
204 std::string RecordKindName =
206 error(IO.mapInteger(RecordLen,
"Record length"));
207 error(IO.mapEnum(RecordKind,
"Record kind: " + RecordKindName));
213 if (IO.isStreaming())
216 return visitTypeBegin(CVR);
221 assert(!MemberKind.hasValue() &&
"Still in a member mapping!");
223 error(IO.endRecord());
231 assert(!MemberKind.hasValue() &&
"Already in a member mapping!");
240 ContinuationLength));
242 MemberKind = Record.
Kind;
243 if (IO.isStreaming()) {
250 error(IO.mapEnum(Record.
Kind,
"Member kind: " + MemberKindName));
257 assert(MemberKind.hasValue() &&
"Not in a member mapping!");
259 if (IO.isReading()) {
260 if (
auto EC = IO.skipPadding())
265 error(IO.endRecord());
270 std::string ModifierNames =
271 getFlagNames(IO, static_cast<uint16_t>(Record.
Modifiers),
280 std::string CallingConvName = getEnumName(
282 std::string FuncOptionNames =
283 getFlagNames(IO, static_cast<uint16_t>(Record.
Options),
286 error(IO.mapEnum(Record.
CallConv,
"CallingConvention: " + CallingConvName));
287 error(IO.mapEnum(Record.
Options,
"FunctionOptions" + FuncOptionNames));
296 std::string CallingConvName = getEnumName(
298 std::string FuncOptionNames =
299 getFlagNames(IO, static_cast<uint16_t>(Record.
Options),
304 error(IO.mapEnum(Record.
CallConv,
"CallingConvention: " + CallingConvName));
305 error(IO.mapEnum(Record.
Options,
"FunctionOptions" + FuncOptionNames));
317 return IO.mapInteger(N,
"Argument");
328 return IO.mapInteger(N,
"Strings");
339 if (IO.isStreaming()) {
340 std::string PtrType = getEnumName(IO,
unsigned(Record.
getPointerKind()),
342 Attr +=
"[ Type: " + PtrType;
344 std::string PtrMode = getEnumName(IO,
unsigned(Record.
getMode()),
346 Attr +=
", Mode: " + PtrMode;
348 auto PtrSizeOf = Record.
getSize();
349 Attr +=
", SizeOf: " +
itostr(PtrSizeOf);
356 Attr +=
", isVolatile";
358 Attr +=
", isUnaligned";
360 Attr +=
", isRestricted";
362 Attr +=
", isThisPtr&";
364 Attr +=
", isThisPtr&&";
377 std::string PtrMemberGetRepresentation = getEnumName(
380 "Representation: " + PtrMemberGetRepresentation));
389 error(IO.mapEncodedInteger(Record.
Size,
"SizeOf"));
390 error(IO.mapStringZ(Record.
Name,
"Name"));
396 assert((CVR.
kind() == TypeLeafKind::LF_STRUCTURE) ||
397 (CVR.
kind() == TypeLeafKind::LF_CLASS) ||
398 (CVR.
kind() == TypeLeafKind::LF_INTERFACE));
400 std::string PropertiesNames =
401 getFlagNames(IO, static_cast<uint16_t>(Record.
Options),
404 error(IO.mapEnum(Record.
Options,
"Properties" + PropertiesNames));
408 error(IO.mapEncodedInteger(Record.
Size,
"SizeOf"));
416 std::string PropertiesNames =
417 getFlagNames(IO, static_cast<uint16_t>(Record.
Options),
420 error(IO.mapEnum(Record.
Options,
"Properties" + PropertiesNames));
422 error(IO.mapEncodedInteger(Record.
Size,
"SizeOf"));
430 std::string PropertiesNames =
431 getFlagNames(IO, static_cast<uint16_t>(Record.
Options),
434 error(IO.mapEnum(Record.
Options,
"Properties" + PropertiesNames));
444 error(IO.mapInteger(Record.
Type,
"Type"));
454 if (!IO.isReading()) {
457 error(IO.mapInteger(Size,
"VFEntryCount"));
462 Byte |=
static_cast<uint8_t
>(Slots[
SlotIndex + 1]);
464 error(IO.mapInteger(Byte));
467 error(IO.mapInteger(Size));
470 error(IO.mapInteger(Byte));
471 Record.
Slots.push_back(static_cast<VFTableSlotKind>(Byte & 0xF));
473 Record.
Slots.push_back(static_cast<VFTableSlotKind>(Byte >> 4));
485 if (!IO.isReading()) {
487 NamesLen +=
Name.size() + 1;
489 error(IO.mapInteger(NamesLen));
490 error(IO.mapVectorTail(
493 return IO.mapStringZ(S,
"MethodName");
501 error(IO.mapInteger(Record.
Id,
"Id"));
509 error(IO.mapInteger(Record.
UDT,
"UDT"));
518 error(IO.mapInteger(Record.
UDT,
"UDT"));
529 error(IO.mapStringZ(Record.
Name,
"Name"));
538 error(IO.mapStringZ(Record.
Name,
"Name"));
548 return IO.mapInteger(N,
"Argument");
559 error(IO.mapVectorTail(Record.
Methods, MapOneMethodRecord(
true),
"Method"));
566 if (IO.isStreaming()) {
570 error(IO.mapByteVectorTail(Record.
Data));
578 error(IO.mapInteger(Record.
Age,
"Age"));
579 error(IO.mapStringZ(Record.
Name,
"Name"));
584 std::string ModeName =
586 error(IO.mapEnum(Record.
Mode,
"Mode: " + ModeName));
592 std::string
Attrs = getMemberAttributes(
595 error(IO.mapInteger(Record.
Type,
"BaseType"));
596 error(IO.mapEncodedInteger(Record.
Offset,
"BaseOffset"));
603 std::string
Attrs = getMemberAttributes(
608 error(IO.mapEncodedInteger(Record.
Value,
"EnumValue"));
609 error(IO.mapStringZ(Record.
Name,
"Name"));
616 std::string
Attrs = getMemberAttributes(
619 error(IO.mapInteger(Record.
Type,
"Type"));
621 error(IO.mapStringZ(Record.
Name,
"Name"));
630 error(IO.mapStringZ(Record.
Name,
"Name"));
637 const bool IsFromOverloadList = (
TypeKind == LF_METHODLIST);
638 MapOneMethodRecord Mapper(IsFromOverloadList);
639 return Mapper(IO, Record);
645 error(IO.mapInteger(Padding,
"Padding"));
646 error(IO.mapInteger(Record.
Type,
"Type"));
647 error(IO.mapStringZ(Record.
Name,
"Name"));
655 std::string
Attrs = getMemberAttributes(
658 error(IO.mapInteger(Record.
Type,
"Type"));
659 error(IO.mapStringZ(Record.
Name,
"Name"));
667 std::string
Attrs = getMemberAttributes(
681 error(IO.mapInteger(Padding,
"Padding"));
682 error(IO.mapInteger(Record.
Type,
"Type"));
690 error(IO.mapInteger(Padding,
"Padding"));
MemberAccess getAccess() const
LLVM_NODISCARD StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
MemberAccess getAccess() const
This class represents lattice values for constants.
ArrayRef< EnumEntry< uint16_t > > getTypeModifierNames()
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
bool isRValueReferenceThisPtr() const
void push_back(const T &Elt)
MemberAccess getAccess() const
MemberAccess getAccess() const
Error visitMemberRecordStream(ArrayRef< uint8_t > FieldList, TypeVisitorCallbacks &Callbacks)
ArrayRef< EnumEntry< uint16_t > > getClassOptionNames()
MethodKind getMethodKind() const
Error visitMemberEnd(CVMemberRecord &Record) override
bool isLValueReferenceThisPtr() const
TypeIndex OverriddenVFTable
bool hasUniqueName() const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Error visitTypeEnd(CVType &Record) override
static const EnumEntry< TypeLeafKind > LeafTypeNames[]
ArrayRef< EnumEntry< uint8_t > > getPtrKindNames()
std::string itostr(int64_t X)
uint32_t maxFieldLength() const
static Error visitKnownRecord(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks)
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
PointerMode getMode() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
TypeIndex ContinuationIndex
std::vector< TypeIndex > StringIndices
MemberAccess getAccess() const
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
ArrayRef< EnumEntry< uint16_t > > getLabelTypeEnum()
static StringRef getLeafTypeName(TypeLeafKind LT)
ArrayRef< EnumEntry< uint16_t > > getPtrMemberRepNames()
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
static Error visitKnownMember(CVMemberRecord &Record, TypeVisitorCallbacks &Callbacks)
size_t size() const
size - Get the array size.
Optional< MemberPointerInfo > MemberInfo
LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records together.
std::vector< TypeIndex > ArgIndices
For method overload sets. LF_METHOD.
MethodOptions getOptions() const
PointerKind getPointerKind() const
std::vector< StringRef > MethodNames
ModifierOptions Modifiers
bool isPointerToMember() const
ArrayRef< EnumEntry< uint16_t > > getMethodOptionNames()
ArrayRef< EnumEntry< uint8_t > > getFunctionOptionEnum()
ArrayRef< EnumEntry< uint8_t > > getPtrModeNames()
static constexpr uint32_t ContinuationLength
Error mapInteger(TypeIndex &TypeInd, const Twine &Comment="")
CallingConvention CallConv
uint32_t getIndex() const
void sort(IteratorTy Start, IteratorTy End)
int32_t ThisPointerAdjustment
static ErrorSuccess success()
Create a success value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static Error mapNameAndUniqueName(CodeViewRecordIO &IO, StringRef &Name, StringRef &UniqueName, bool HasUniqueName)
CallingConvention CallConv
MemberAccess getAccess() const
MethodOptions
Equivalent to CV_fldattr_t bitfield.
Error mapStringZ(StringRef &Value, const Twine &Comment="")
std::vector< OneMethodRecord > Methods
ArrayRef< EnumEntry< uint8_t > > getMemberAccessNames()
ArrayRef< EnumEntry< uint16_t > > getMemberKindNames()
StringRef PrecompFilePath
MemberAccess
Source-level access specifier. (CV_access_e)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::vector< VFTableSlotKind > Slots
ArrayRef< VFTableSlotKind > getSlots() const
LLVM Value Representation.
LLVM_NODISCARD StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
Lightweight error class with error context and mandatory checking.
ArrayRef< EnumEntry< uint8_t > > getCallingConventions()
StringRef - Represent a constant reference to a string, i.e.
SlotIndex - An opaque wrapper around machine indexes.
SmallVector< TypeIndex, MaxArgs > ArgIndices
Error visitMemberBegin(CVMemberRecord &Record) override
PointerToMemberRepresentation Representation
std::string utohexstr(uint64_t X, bool LowerCase=false)
bool isIntroducingVirtual() const