LLVM  8.0.0svn
TypeRecord.h
Go to the documentation of this file.
1 //===- TypeRecord.h ---------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H
12 
13 #include "llvm/ADT/APSInt.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/Optional.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Support/Endian.h"
25 #include <algorithm>
26 #include <cstdint>
27 #include <vector>
28 
29 namespace llvm {
30 namespace codeview {
31 
35 
38 
42 };
45 
46 /// Equvalent to CV_fldattr_t in cvinfo.h.
48  uint16_t Attrs = 0;
49 
50  enum {
51  MethodKindShift = 2,
52  };
53 
54  MemberAttributes() = default;
55 
56  explicit MemberAttributes(MemberAccess Access)
57  : Attrs(static_cast<uint16_t>(Access)) {}
58 
60  Attrs = static_cast<uint16_t>(Access);
61  Attrs |= (static_cast<uint16_t>(Kind) << MethodKindShift);
62  Attrs |= static_cast<uint16_t>(Flags);
63  }
64 
65  /// Get the access specifier. Valid for any kind of member.
67  return MemberAccess(unsigned(Attrs) & unsigned(MethodOptions::AccessMask));
68  }
69 
70  /// Indicates if a method is defined with friend, virtual, static, etc.
72  return MethodKind(
73  (unsigned(Attrs) & unsigned(MethodOptions::MethodKindMask)) >>
74  MethodKindShift);
75  }
76 
77  /// Get the flags that are not included in access control or method
78  /// properties.
80  return MethodOptions(
81  unsigned(Attrs) &
83  }
84 
85  /// Is this method virtual.
86  bool isVirtual() const {
87  auto MP = getMethodKind();
88  return MP != MethodKind::Vanilla && MP != MethodKind::Friend &&
89  MP != MethodKind::Static;
90  }
91 
92  /// Does this member introduce a new virtual method.
93  bool isIntroducedVirtual() const {
94  auto MP = getMethodKind();
95  return MP == MethodKind::IntroducingVirtual ||
97  }
98 };
99 
100 // Does not correspond to any tag, this is the tail of an LF_POINTER record
101 // if it represents a member pointer.
103 public:
104  MemberPointerInfo() = default;
105 
106  MemberPointerInfo(TypeIndex ContainingType,
107  PointerToMemberRepresentation Representation)
108  : ContainingType(ContainingType), Representation(Representation) {}
109 
110  TypeIndex getContainingType() const { return ContainingType; }
112  return Representation;
113  }
114 
117 };
118 
119 class TypeRecord {
120 protected:
121  TypeRecord() = default;
122  explicit TypeRecord(TypeRecordKind Kind) : Kind(Kind) {}
123 
124 public:
125  TypeRecordKind getKind() const { return Kind; }
126 
128 };
129 
130 // LF_MODIFIER
131 class ModifierRecord : public TypeRecord {
132 public:
133  ModifierRecord() = default;
135  ModifierRecord(TypeIndex ModifiedType, ModifierOptions Modifiers)
136  : TypeRecord(TypeRecordKind::Modifier), ModifiedType(ModifiedType),
137  Modifiers(Modifiers) {}
138 
139  TypeIndex getModifiedType() const { return ModifiedType; }
140  ModifierOptions getModifiers() const { return Modifiers; }
141 
144 };
145 
146 // LF_PROCEDURE
147 class ProcedureRecord : public TypeRecord {
148 public:
149  ProcedureRecord() = default;
152  FunctionOptions Options, uint16_t ParameterCount,
153  TypeIndex ArgumentList)
154  : TypeRecord(TypeRecordKind::Procedure), ReturnType(ReturnType),
155  CallConv(CallConv), Options(Options), ParameterCount(ParameterCount),
156  ArgumentList(ArgumentList) {}
157 
158  TypeIndex getReturnType() const { return ReturnType; }
159  CallingConvention getCallConv() const { return CallConv; }
160  FunctionOptions getOptions() const { return Options; }
161  uint16_t getParameterCount() const { return ParameterCount; }
162  TypeIndex getArgumentList() const { return ArgumentList; }
163 
167  uint16_t ParameterCount;
169 };
170 
171 // LF_MFUNCTION
173 public:
174  MemberFunctionRecord() = default;
176 
178  TypeIndex ThisType, CallingConvention CallConv,
179  FunctionOptions Options, uint16_t ParameterCount,
180  TypeIndex ArgumentList, int32_t ThisPointerAdjustment)
181  : TypeRecord(TypeRecordKind::MemberFunction), ReturnType(ReturnType),
182  ClassType(ClassType), ThisType(ThisType), CallConv(CallConv),
183  Options(Options), ParameterCount(ParameterCount),
184  ArgumentList(ArgumentList),
185  ThisPointerAdjustment(ThisPointerAdjustment) {}
186 
187  TypeIndex getReturnType() const { return ReturnType; }
188  TypeIndex getClassType() const { return ClassType; }
189  TypeIndex getThisType() const { return ThisType; }
190  CallingConvention getCallConv() const { return CallConv; }
191  FunctionOptions getOptions() const { return Options; }
192  uint16_t getParameterCount() const { return ParameterCount; }
193  TypeIndex getArgumentList() const { return ArgumentList; }
194  int32_t getThisPointerAdjustment() const { return ThisPointerAdjustment; }
195 
201  uint16_t ParameterCount;
204 };
205 
206 // LF_LABEL
207 class LabelRecord : public TypeRecord {
208 public:
209  LabelRecord() = default;
211 
213 
215 };
216 
217 // LF_MFUNC_ID
219 public:
220  MemberFuncIdRecord() = default;
223  StringRef Name)
224  : TypeRecord(TypeRecordKind::MemberFuncId), ClassType(ClassType),
225  FunctionType(FunctionType), Name(Name) {}
226 
227  TypeIndex getClassType() const { return ClassType; }
229  StringRef getName() const { return Name; }
230 
234 };
235 
236 // LF_ARGLIST
237 class ArgListRecord : public TypeRecord {
238 public:
239  ArgListRecord() = default;
241 
243  : TypeRecord(Kind), ArgIndices(Indices) {}
244 
245  ArrayRef<TypeIndex> getIndices() const { return ArgIndices; }
246 
247  std::vector<TypeIndex> ArgIndices;
248 };
249 
250 // LF_SUBSTR_LIST
251 class StringListRecord : public TypeRecord {
252 public:
253  StringListRecord() = default;
255 
257  : TypeRecord(Kind), StringIndices(Indices) {}
258 
259  ArrayRef<TypeIndex> getIndices() const { return StringIndices; }
260 
261  std::vector<TypeIndex> StringIndices;
262 };
263 
264 // LF_POINTER
265 class PointerRecord : public TypeRecord {
266 public:
267  // ---------------------------XXXXX
268  static const uint32_t PointerKindShift = 0;
269  static const uint32_t PointerKindMask = 0x1F;
270 
271  // ------------------------XXX-----
272  static const uint32_t PointerModeShift = 5;
273  static const uint32_t PointerModeMask = 0x07;
274 
275  // ----------XXX------XXXXX--------
276  static const uint32_t PointerOptionMask = 0x381f00;
277 
278  // -------------XXXXXX------------
279  static const uint32_t PointerSizeShift = 13;
280  static const uint32_t PointerSizeMask = 0xFF;
281 
282  PointerRecord() = default;
284 
286  : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType),
287  Attrs(Attrs) {}
288 
290  PointerOptions PO, uint8_t Size)
291  : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType),
292  Attrs(calcAttrs(PK, PM, PO, Size)) {}
293 
295  PointerOptions PO, uint8_t Size, const MemberPointerInfo &MPI)
296  : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType),
297  Attrs(calcAttrs(PK, PM, PO, Size)), MemberInfo(MPI) {}
298 
299  TypeIndex getReferentType() const { return ReferentType; }
300 
302  return static_cast<PointerKind>((Attrs >> PointerKindShift) &
303  PointerKindMask);
304  }
305 
307  return static_cast<PointerMode>((Attrs >> PointerModeShift) &
308  PointerModeMask);
309  }
310 
312  return static_cast<PointerOptions>(Attrs & PointerOptionMask);
313  }
314 
315  uint8_t getSize() const {
316  return (Attrs >> PointerSizeShift) & PointerSizeMask;
317  }
318 
319  MemberPointerInfo getMemberInfo() const { return *MemberInfo; }
320 
321  bool isPointerToMember() const {
322  return getMode() == PointerMode::PointerToDataMember ||
324  }
325 
326  bool isFlat() const { return !!(Attrs & uint32_t(PointerOptions::Flat32)); }
327  bool isConst() const { return !!(Attrs & uint32_t(PointerOptions::Const)); }
328 
329  bool isVolatile() const {
331  }
332 
333  bool isUnaligned() const {
335  }
336 
337  bool isRestrict() const {
339  }
340 
343  }
344 
347  }
348 
352 
354  uint8_t Size) {
355  Attrs = calcAttrs(PK, PM, PO, Size);
356  }
357 
358 private:
359  static uint32_t calcAttrs(PointerKind PK, PointerMode PM, PointerOptions PO,
360  uint8_t Size) {
361  uint32_t A = 0;
362  A |= static_cast<uint32_t>(PK);
363  A |= static_cast<uint32_t>(PO);
364  A |= (static_cast<uint32_t>(PM) << PointerModeShift);
365  A |= (static_cast<uint32_t>(Size) << PointerSizeShift);
366  return A;
367  }
368 };
369 
370 // LF_NESTTYPE
371 class NestedTypeRecord : public TypeRecord {
372 public:
373  NestedTypeRecord() = default;
376  : TypeRecord(TypeRecordKind::NestedType), Type(Type), Name(Name) {}
377 
378  TypeIndex getNestedType() const { return Type; }
379  StringRef getName() const { return Name; }
380 
383 };
384 
385 // LF_FIELDLIST
386 class FieldListRecord : public TypeRecord {
387 public:
388  FieldListRecord() = default;
391  : TypeRecord(TypeRecordKind::FieldList), Data(Data) {}
392 
394 };
395 
396 // LF_ARRAY
397 class ArrayRecord : public TypeRecord {
398 public:
399  ArrayRecord() = default;
401  ArrayRecord(TypeIndex ElementType, TypeIndex IndexType, uint64_t Size,
402  StringRef Name)
403  : TypeRecord(TypeRecordKind::Array), ElementType(ElementType),
404  IndexType(IndexType), Size(Size), Name(Name) {}
405 
406  TypeIndex getElementType() const { return ElementType; }
407  TypeIndex getIndexType() const { return IndexType; }
408  uint64_t getSize() const { return Size; }
409  StringRef getName() const { return Name; }
410 
413  uint64_t Size;
415 };
416 
417 class TagRecord : public TypeRecord {
418 protected:
419  TagRecord() = default;
421  TagRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options,
423  : TypeRecord(Kind), MemberCount(MemberCount), Options(Options),
424  FieldList(FieldList), Name(Name), UniqueName(UniqueName) {}
425 
426 public:
427  static const int HfaKindShift = 11;
428  static const int HfaKindMask = 0x1800;
429  static const int WinRTKindShift = 14;
430  static const int WinRTKindMask = 0xC000;
431 
432  bool hasUniqueName() const {
433  return (Options & ClassOptions::HasUniqueName) != ClassOptions::None;
434  }
435 
436  bool isNested() const {
437  return (Options & ClassOptions::Nested) != ClassOptions::None;
438  }
439 
440  bool isForwardRef() const {
442  }
443 
444  bool containsNestedClass() const {
446  }
447 
448  bool isScoped() const {
449  return (Options & ClassOptions::Scoped) != ClassOptions::None;
450  }
451 
452  uint16_t getMemberCount() const { return MemberCount; }
453  ClassOptions getOptions() const { return Options; }
454  TypeIndex getFieldList() const { return FieldList; }
455  StringRef getName() const { return Name; }
456  StringRef getUniqueName() const { return UniqueName; }
457 
458  uint16_t MemberCount;
463 };
464 
465 // LF_CLASS, LF_STRUCTURE, LF_INTERFACE
466 class ClassRecord : public TagRecord {
467 public:
468  ClassRecord() = default;
470  ClassRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options,
471  TypeIndex FieldList, TypeIndex DerivationList,
472  TypeIndex VTableShape, uint64_t Size, StringRef Name,
473  StringRef UniqueName)
474  : TagRecord(Kind, MemberCount, Options, FieldList, Name, UniqueName),
475  DerivationList(DerivationList), VTableShape(VTableShape), Size(Size) {}
476 
477  HfaKind getHfa() const {
478  uint16_t Value = static_cast<uint16_t>(Options);
479  Value = (Value & HfaKindMask) >> HfaKindShift;
480  return static_cast<HfaKind>(Value);
481  }
482 
484  uint16_t Value = static_cast<uint16_t>(Options);
485  Value = (Value & WinRTKindMask) >> WinRTKindShift;
486  return static_cast<WindowsRTClassKind>(Value);
487  }
488 
489  TypeIndex getDerivationList() const { return DerivationList; }
490  TypeIndex getVTableShape() const { return VTableShape; }
491  uint64_t getSize() const { return Size; }
492 
495  uint64_t Size;
496 };
497 
498 // LF_UNION
499 struct UnionRecord : public TagRecord {
500  UnionRecord() = default;
502  UnionRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList,
503  uint64_t Size, StringRef Name, StringRef UniqueName)
504  : TagRecord(TypeRecordKind::Union, MemberCount, Options, FieldList, Name,
505  UniqueName),
506  Size(Size) {}
507 
508  HfaKind getHfa() const {
509  uint16_t Value = static_cast<uint16_t>(Options);
510  Value = (Value & HfaKindMask) >> HfaKindShift;
511  return static_cast<HfaKind>(Value);
512  }
513 
514  uint64_t getSize() const { return Size; }
515 
516  uint64_t Size;
517 };
518 
519 // LF_ENUM
520 class EnumRecord : public TagRecord {
521 public:
522  EnumRecord() = default;
524  EnumRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList,
525  StringRef Name, StringRef UniqueName, TypeIndex UnderlyingType)
526  : TagRecord(TypeRecordKind::Enum, MemberCount, Options, FieldList, Name,
527  UniqueName),
528  UnderlyingType(UnderlyingType) {}
529 
530  TypeIndex getUnderlyingType() const { return UnderlyingType; }
531 
533 };
534 
535 // LF_BITFIELD
536 class BitFieldRecord : public TypeRecord {
537 public:
538  BitFieldRecord() = default;
540  BitFieldRecord(TypeIndex Type, uint8_t BitSize, uint8_t BitOffset)
541  : TypeRecord(TypeRecordKind::BitField), Type(Type), BitSize(BitSize),
542  BitOffset(BitOffset) {}
543 
544  TypeIndex getType() const { return Type; }
545  uint8_t getBitOffset() const { return BitOffset; }
546  uint8_t getBitSize() const { return BitSize; }
547 
549  uint8_t BitSize;
550  uint8_t BitOffset;
551 };
552 
553 // LF_VTSHAPE
555 public:
556  VFTableShapeRecord() = default;
559  : TypeRecord(TypeRecordKind::VFTableShape), SlotsRef(Slots) {}
560  explicit VFTableShapeRecord(std::vector<VFTableSlotKind> Slots)
561  : TypeRecord(TypeRecordKind::VFTableShape), Slots(std::move(Slots)) {}
562 
564  if (!SlotsRef.empty())
565  return SlotsRef;
566  return Slots;
567  }
568 
569  uint32_t getEntryCount() const { return getSlots().size(); }
570 
572  std::vector<VFTableSlotKind> Slots;
573 };
574 
575 // LF_TYPESERVER2
577 public:
578  TypeServer2Record() = default;
581  : TypeRecord(TypeRecordKind::TypeServer2), Age(Age), Name(Name) {
582  assert(GuidStr.size() == 16 && "guid isn't 16 bytes");
583  ::memcpy(Guid.Guid, GuidStr.data(), 16);
584  }
585 
586  const GUID &getGuid() const { return Guid; }
587  uint32_t getAge() const { return Age; }
588  StringRef getName() const { return Name; }
589 
593 };
594 
595 // LF_STRING_ID
596 class StringIdRecord : public TypeRecord {
597 public:
598  StringIdRecord() = default;
601  : TypeRecord(TypeRecordKind::StringId), Id(Id), String(String) {}
602 
603  TypeIndex getId() const { return Id; }
604  StringRef getString() const { return String; }
605 
608 };
609 
610 // LF_FUNC_ID
611 class FuncIdRecord : public TypeRecord {
612 public:
613  FuncIdRecord() = default;
616  : TypeRecord(TypeRecordKind::FuncId), ParentScope(ParentScope),
617  FunctionType(FunctionType), Name(Name) {}
618 
619  TypeIndex getParentScope() const { return ParentScope; }
621  StringRef getName() const { return Name; }
622 
626 };
627 
628 // LF_UDT_SRC_LINE
630 public:
631  UdtSourceLineRecord() = default;
633  UdtSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile, uint32_t LineNumber)
634  : TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT),
635  SourceFile(SourceFile), LineNumber(LineNumber) {}
636 
637  TypeIndex getUDT() const { return UDT; }
638  TypeIndex getSourceFile() const { return SourceFile; }
639  uint32_t getLineNumber() const { return LineNumber; }
640 
644 };
645 
646 // LF_UDT_MOD_SRC_LINE
648 public:
649  UdtModSourceLineRecord() = default;
652  uint32_t LineNumber, uint16_t Module)
653  : TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT),
654  SourceFile(SourceFile), LineNumber(LineNumber), Module(Module) {}
655 
656  TypeIndex getUDT() const { return UDT; }
657  TypeIndex getSourceFile() const { return SourceFile; }
658  uint32_t getLineNumber() const { return LineNumber; }
659  uint16_t getModule() const { return Module; }
660 
664  uint16_t Module;
665 };
666 
667 // LF_BUILDINFO
668 class BuildInfoRecord : public TypeRecord {
669 public:
670  BuildInfoRecord() = default;
673  : TypeRecord(TypeRecordKind::BuildInfo),
674  ArgIndices(ArgIndices.begin(), ArgIndices.end()) {}
675 
676  ArrayRef<TypeIndex> getArgs() const { return ArgIndices; }
677 
678  /// Indices of known build info arguments.
680  CurrentDirectory, ///< Absolute CWD path
681  BuildTool, ///< Absolute compiler path
682  SourceFile, ///< Path to main source file, relative or absolute
683  TypeServerPDB, ///< Absolute path of type server PDB (/Fd)
684  CommandLine, ///< Full canonical command line (maybe -cc1)
685  MaxArgs
686  };
687 
689 };
690 
691 // LF_VFTABLE
692 class VFTableRecord : public TypeRecord {
693 public:
694  VFTableRecord() = default;
696  VFTableRecord(TypeIndex CompleteClass, TypeIndex OverriddenVFTable,
697  uint32_t VFPtrOffset, StringRef Name,
698  ArrayRef<StringRef> Methods)
699  : TypeRecord(TypeRecordKind::VFTable), CompleteClass(CompleteClass),
700  OverriddenVFTable(OverriddenVFTable), VFPtrOffset(VFPtrOffset) {
701  MethodNames.push_back(Name);
702  MethodNames.insert(MethodNames.end(), Methods.begin(), Methods.end());
703  }
704 
705  TypeIndex getCompleteClass() const { return CompleteClass; }
706  TypeIndex getOverriddenVTable() const { return OverriddenVFTable; }
707  uint32_t getVFPtrOffset() const { return VFPtrOffset; }
708  StringRef getName() const { return makeArrayRef(MethodNames).front(); }
709 
711  return makeArrayRef(MethodNames).drop_front();
712  }
713 
717  std::vector<StringRef> MethodNames;
718 };
719 
720 // LF_ONEMETHOD
721 class OneMethodRecord : public TypeRecord {
722 public:
723  OneMethodRecord() = default;
726  StringRef Name)
727  : TypeRecord(TypeRecordKind::OneMethod), Type(Type), Attrs(Attrs),
728  VFTableOffset(VFTableOffset), Name(Name) {}
730  MethodOptions Options, int32_t VFTableOffset, StringRef Name)
731  : TypeRecord(TypeRecordKind::OneMethod), Type(Type),
732  Attrs(Access, MK, Options), VFTableOffset(VFTableOffset), Name(Name) {}
733 
734  TypeIndex getType() const { return Type; }
735  MethodKind getMethodKind() const { return Attrs.getMethodKind(); }
736  MethodOptions getOptions() const { return Attrs.getFlags(); }
737  MemberAccess getAccess() const { return Attrs.getAccess(); }
738  int32_t getVFTableOffset() const { return VFTableOffset; }
739  StringRef getName() const { return Name; }
740 
741  bool isIntroducingVirtual() const {
744  }
745 
748  int32_t VFTableOffset;
750 };
751 
752 // LF_METHODLIST
754 public:
755  MethodOverloadListRecord() = default;
758  : TypeRecord(TypeRecordKind::MethodOverloadList), Methods(Methods) {}
759 
760  ArrayRef<OneMethodRecord> getMethods() const { return Methods; }
761 
762  std::vector<OneMethodRecord> Methods;
763 };
764 
765 /// For method overload sets. LF_METHOD
767 public:
768  OverloadedMethodRecord() = default;
770  OverloadedMethodRecord(uint16_t NumOverloads, TypeIndex MethodList,
771  StringRef Name)
772  : TypeRecord(TypeRecordKind::OverloadedMethod),
773  NumOverloads(NumOverloads), MethodList(MethodList), Name(Name) {}
774 
775  uint16_t getNumOverloads() const { return NumOverloads; }
776  TypeIndex getMethodList() const { return MethodList; }
777  StringRef getName() const { return Name; }
778 
779  uint16_t NumOverloads;
782 };
783 
784 // LF_MEMBER
785 class DataMemberRecord : public TypeRecord {
786 public:
787  DataMemberRecord() = default;
790  StringRef Name)
791  : TypeRecord(TypeRecordKind::DataMember), Attrs(Attrs), Type(Type),
792  FieldOffset(Offset), Name(Name) {}
794  StringRef Name)
795  : TypeRecord(TypeRecordKind::DataMember), Attrs(Access), Type(Type),
796  FieldOffset(Offset), Name(Name) {}
797 
798  MemberAccess getAccess() const { return Attrs.getAccess(); }
799  TypeIndex getType() const { return Type; }
800  uint64_t getFieldOffset() const { return FieldOffset; }
801  StringRef getName() const { return Name; }
802 
805  uint64_t FieldOffset;
807 };
808 
809 // LF_STMEMBER
811 public:
812  StaticDataMemberRecord() = default;
815  : TypeRecord(TypeRecordKind::StaticDataMember), Attrs(Attrs), Type(Type),
816  Name(Name) {}
818  : TypeRecord(TypeRecordKind::StaticDataMember), Attrs(Access), Type(Type),
819  Name(Name) {}
820 
821  MemberAccess getAccess() const { return Attrs.getAccess(); }
822  TypeIndex getType() const { return Type; }
823  StringRef getName() const { return Name; }
824 
828 };
829 
830 // LF_ENUMERATE
831 class EnumeratorRecord : public TypeRecord {
832 public:
833  EnumeratorRecord() = default;
836  : TypeRecord(TypeRecordKind::Enumerator), Attrs(Attrs),
837  Value(std::move(Value)), Name(Name) {}
840  Value(std::move(Value)), Name(Name) {}
841 
842  MemberAccess getAccess() const { return Attrs.getAccess(); }
843  APSInt getValue() const { return Value; }
844  StringRef getName() const { return Name; }
845 
849 };
850 
851 // LF_VFUNCTAB
852 class VFPtrRecord : public TypeRecord {
853 public:
854  VFPtrRecord() = default;
857  : TypeRecord(TypeRecordKind::VFPtr), Type(Type) {}
858 
859  TypeIndex getType() const { return Type; }
860 
862 };
863 
864 // LF_BCLASS, LF_BINTERFACE
865 class BaseClassRecord : public TypeRecord {
866 public:
867  BaseClassRecord() = default;
870  : TypeRecord(TypeRecordKind::BaseClass), Attrs(Attrs), Type(Type),
871  Offset(Offset) {}
873  : TypeRecord(TypeRecordKind::BaseClass), Attrs(Access), Type(Type),
874  Offset(Offset) {}
875 
876  MemberAccess getAccess() const { return Attrs.getAccess(); }
877  TypeIndex getBaseType() const { return Type; }
878  uint64_t getBaseOffset() const { return Offset; }
879 
882  uint64_t Offset;
883 };
884 
885 // LF_VBCLASS, LF_IVBCLASS
887 public:
888  VirtualBaseClassRecord() = default;
891  TypeIndex BaseType, TypeIndex VBPtrType,
892  uint64_t Offset, uint64_t Index)
893  : TypeRecord(Kind), Attrs(Attrs), BaseType(BaseType),
894  VBPtrType(VBPtrType), VBPtrOffset(Offset), VTableIndex(Index) {}
896  TypeIndex BaseType, TypeIndex VBPtrType,
897  uint64_t Offset, uint64_t Index)
898  : TypeRecord(Kind), Attrs(Access), BaseType(BaseType),
899  VBPtrType(VBPtrType), VBPtrOffset(Offset), VTableIndex(Index) {}
900 
901  MemberAccess getAccess() const { return Attrs.getAccess(); }
902  TypeIndex getBaseType() const { return BaseType; }
903  TypeIndex getVBPtrType() const { return VBPtrType; }
904  uint64_t getVBPtrOffset() const { return VBPtrOffset; }
905  uint64_t getVTableIndex() const { return VTableIndex; }
906 
910  uint64_t VBPtrOffset;
911  uint64_t VTableIndex;
912 };
913 
914 /// LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records
915 /// together. The first will end in an LF_INDEX record that points to the next.
917 public:
918  ListContinuationRecord() = default;
921  : TypeRecord(TypeRecordKind::ListContinuation),
922  ContinuationIndex(ContinuationIndex) {}
923 
924  TypeIndex getContinuationIndex() const { return ContinuationIndex; }
925 
927 };
928 
929 // LF_PRECOMP
930 class PrecompRecord : public TypeRecord {
931 public:
932  PrecompRecord() = default;
934 
935  uint32_t getStartTypeIndex() const { return StartTypeIndex; }
936  uint32_t getTypesCount() const { return TypesCount; }
937  uint32_t getSignature() const { return Signature; }
938  StringRef getPrecompFilePath() const { return PrecompFilePath; }
939 
944 };
945 
946 // LF_ENDPRECOMP
947 class EndPrecompRecord : public TypeRecord {
948 public:
949  EndPrecompRecord() = default;
951 
952  uint32_t getSignature() const { return Signature; }
953 
955 };
956 
957 } // end namespace codeview
958 } // end namespace llvm
959 
960 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H
MemberAccess getAccess() const
Definition: TypeRecord.h:842
Profile::FuncID FuncId
Definition: Profile.cpp:321
PointerKind
Equivalent to CV_ptrtype_e.
Definition: CodeView.h:328
TypeIndex getIndexType() const
Definition: TypeRecord.h:407
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:259
int32_t getThisPointerAdjustment() const
Definition: TypeRecord.h:194
UdtSourceLineRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:632
MemberAttributes(MemberAccess Access)
Definition: TypeRecord.h:56
VirtualBaseClassRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:889
uint16_t getMemberCount() const
Definition: TypeRecord.h:452
uint64_t getSize() const
Definition: TypeRecord.h:408
BuildInfoRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:671
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:250
uint32_t getSignature() const
Definition: TypeRecord.h:937
MemberFunctionRecord(TypeIndex ReturnType, TypeIndex ClassType, TypeIndex ThisType, CallingConvention CallConv, FunctionOptions Options, uint16_t ParameterCount, TypeIndex ArgumentList, int32_t ThisPointerAdjustment)
Definition: TypeRecord.h:177
SI Whole Quad Mode
This class represents lattice values for constants.
Definition: AllocatorList.h:24
uint64_t getSize() const
Definition: TypeRecord.h:491
LabelRecord(LabelType Mode)
Definition: TypeRecord.h:212
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:34
TagRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, StringRef Name, StringRef UniqueName)
Definition: TypeRecord.h:421
MethodOverloadListRecord(ArrayRef< OneMethodRecord > Methods)
Definition: TypeRecord.h:757
iterator begin() const
Definition: ArrayRef.h:137
StaticDataMemberRecord(MemberAttributes Attrs, TypeIndex Type, StringRef Name)
Definition: TypeRecord.h:814
ArrayRef< uint8_t > Data
Definition: TypeRecord.h:41
VirtualBaseClassRecord(TypeRecordKind Kind, MemberAttributes Attrs, TypeIndex BaseType, TypeIndex VBPtrType, uint64_t Offset, uint64_t Index)
Definition: TypeRecord.h:890
TypeIndex getBaseType() const
Definition: TypeRecord.h:877
bool isRValueReferenceThisPtr() const
Definition: TypeRecord.h:345
ArrayRef< StringRef > getMethodNames() const
Definition: TypeRecord.h:710
MemberAccess getAccess() const
Definition: TypeRecord.h:737
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
StringIdRecord(TypeIndex Id, StringRef String)
Definition: TypeRecord.h:600
BuildInfoRecord(ArrayRef< TypeIndex > ArgIndices)
Definition: TypeRecord.h:672
NestedTypeRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:374
OverloadedMethodRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:769
TypeIndex getReferentType() const
Definition: TypeRecord.h:299
MemberPointerInfo getMemberInfo() const
Definition: TypeRecord.h:319
PointerRecord(TypeIndex ReferentType, uint32_t Attrs)
Definition: TypeRecord.h:285
ClassRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, TypeIndex DerivationList, TypeIndex VTableShape, uint64_t Size, StringRef Name, StringRef UniqueName)
Definition: TypeRecord.h:470
TypeIndex getType() const
Definition: TypeRecord.h:544
FieldListRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:389
FieldListRecord(ArrayRef< uint8_t > Data)
Definition: TypeRecord.h:390
ArrayRef< uint8_t > Data
Definition: TypeRecord.h:393
TypeServer2Record(StringRef GuidStr, uint32_t Age, StringRef Name)
Definition: TypeRecord.h:580
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
Definition: Endian.h:269
TypeServer2Record(TypeRecordKind Kind)
Definition: TypeRecord.h:579
BitFieldRecord(TypeIndex Type, uint8_t BitSize, uint8_t BitOffset)
Definition: TypeRecord.h:540
WindowsRTClassKind getWinRTKind() const
Definition: TypeRecord.h:483
OneMethodRecord(TypeIndex Type, MemberAttributes Attrs, int32_t VFTableOffset, StringRef Name)
Definition: TypeRecord.h:725
BitFieldRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:539
ArgListRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:240
MethodKind getMethodKind() const
Definition: TypeRecord.h:735
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:128
OneMethodRecord(TypeIndex Type, MemberAccess Access, MethodKind MK, MethodOptions Options, int32_t VFTableOffset, StringRef Name)
Definition: TypeRecord.h:729
TypeIndex getFunctionType() const
Definition: TypeRecord.h:228
EnumRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, StringRef Name, StringRef UniqueName, TypeIndex UnderlyingType)
Definition: TypeRecord.h:524
MemberFunctionRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:175
bool isForwardRef() const
Definition: TypeRecord.h:440
PointerRecord(TypeIndex ReferentType, PointerKind PK, PointerMode PM, PointerOptions PO, uint8_t Size)
Definition: TypeRecord.h:289
bool isLValueReferenceThisPtr() const
Definition: TypeRecord.h:341
StringRef getName() const
Definition: TypeRecord.h:455
bool hasUniqueName() const
Definition: TypeRecord.h:432
DataMemberRecord(MemberAttributes Attrs, TypeIndex Type, uint64_t Offset, StringRef Name)
Definition: TypeRecord.h:789
ArgListRecord(TypeRecordKind Kind, ArrayRef< TypeIndex > Indices)
Definition: TypeRecord.h:242
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Definition: BitVector.h:938
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
StringRef getName() const
Definition: TypeRecord.h:621
StringRef getName() const
Definition: TypeRecord.h:409
ArrayRef< VFTableSlotKind > SlotsRef
Definition: TypeRecord.h:571
This represents the &#39;GUID&#39; type from windows.h.
Definition: GUID.h:22
LabelRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:210
uint64_t getBaseOffset() const
Definition: TypeRecord.h:878
Class to represent function types.
Definition: DerivedTypes.h:103
VirtualBaseClassRecord(TypeRecordKind Kind, MemberAccess Access, TypeIndex BaseType, TypeIndex VBPtrType, uint64_t Offset, uint64_t Index)
Definition: TypeRecord.h:895
OneMethodRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:724
ClassOptions getOptions() const
Definition: TypeRecord.h:453
ModifierOptions
Equivalent to CV_modifier_t.
Definition: CodeView.h:299
BuildInfoArg
Indices of known build info arguments.
Definition: TypeRecord.h:679
static MethodKind getMethodKind(uint16_t Attrs)
TypeIndex getFunctionType() const
Definition: TypeRecord.h:620
LabelType
Equivalent to CV_LABEL_TYPE_e.
Definition: CodeView.h:292
PointerRecord(TypeIndex ReferentType, PointerKind PK, PointerMode PM, PointerOptions PO, uint8_t Size, const MemberPointerInfo &MPI)
Definition: TypeRecord.h:294
PointerMode getMode() const
Definition: TypeRecord.h:306
A 32-bit type reference.
Definition: TypeIndex.h:96
UdtSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile, uint32_t LineNumber)
Definition: TypeRecord.h:633
TypeIndex getElementType() const
Definition: TypeRecord.h:406
TypeIndex getReturnType() const
Definition: TypeRecord.h:158
CallingConvention getCallConv() const
Definition: TypeRecord.h:190
std::vector< TypeIndex > StringIndices
Definition: TypeRecord.h:261
VFTableRecord(TypeIndex CompleteClass, TypeIndex OverriddenVFTable, uint32_t VFPtrOffset, StringRef Name, ArrayRef< StringRef > Methods)
Definition: TypeRecord.h:696
MemberAccess getAccess() const
Definition: TypeRecord.h:798
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Definition: CodeView.h:268
ModifierRecord(TypeIndex ModifiedType, ModifierOptions Modifiers)
Definition: TypeRecord.h:135
ModifierRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:134
EnumeratorRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:834
TypeIndex getFieldList() const
Definition: TypeRecord.h:454
StringRef getString() const
Definition: TypeRecord.h:604
ArrayRef< TypeIndex > getArgs() const
Definition: TypeRecord.h:676
VFTableRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:695
Full canonical command line (maybe -cc1)
Definition: TypeRecord.h:684
TypeRecordKind
Distinguishes individual records in .debug$T or .debug$P section or PDB type stream.
Definition: CodeView.h:27
PointerToMemberRepresentation getRepresentation() const
Definition: TypeRecord.h:111
ListContinuationRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:919
FunctionOptions getOptions() const
Definition: TypeRecord.h:191
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
Definition: Endian.h:271
Absolute path of type server PDB (/Fd)
Definition: TypeRecord.h:683
PointerRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:283
uint32_t getVFPtrOffset() const
Definition: TypeRecord.h:707
bool isIntroducedVirtual() const
Does this member introduce a new virtual method.
Definition: TypeRecord.h:93
Optional< MemberPointerInfo > MemberInfo
Definition: TypeRecord.h:351
NestedTypeRecord(TypeIndex Type, StringRef Name)
Definition: TypeRecord.h:375
LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records together.
Definition: TypeRecord.h:916
StringRef getUniqueName() const
Definition: TypeRecord.h:456
TypeIndex getContainingType() const
Definition: TypeRecord.h:110
std::vector< TypeIndex > ArgIndices
Definition: TypeRecord.h:247
FuncIdRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:614
StringListRecord(TypeRecordKind Kind, ArrayRef< TypeIndex > Indices)
Definition: TypeRecord.h:256
TagRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:420
For method overload sets. LF_METHOD.
Definition: TypeRecord.h:766
OverloadedMethodRecord(uint16_t NumOverloads, TypeIndex MethodList, StringRef Name)
Definition: TypeRecord.h:770
TypeIndex getArgumentList() const
Definition: TypeRecord.h:162
FuncIdRecord(TypeIndex ParentScope, TypeIndex FunctionType, StringRef Name)
Definition: TypeRecord.h:615
MethodOptions getOptions() const
Definition: TypeRecord.h:736
PointerKind getPointerKind() const
Definition: TypeRecord.h:301
std::vector< StringRef > MethodNames
Definition: TypeRecord.h:717
ArrayRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:400
TypeIndex getUnderlyingType() const
Definition: TypeRecord.h:530
UdtModSourceLineRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:650
uint32_t getTypesCount() const
Definition: TypeRecord.h:936
BaseClassRecord(MemberAttributes Attrs, TypeIndex Type, uint64_t Offset)
Definition: TypeRecord.h:869
ListContinuationRecord(TypeIndex ContinuationIndex)
Definition: TypeRecord.h:920
StringListRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:254
uint64_t getSize() const
Definition: TypeRecord.h:514
ProcedureRecord(TypeIndex ReturnType, CallingConvention CallConv, FunctionOptions Options, uint16_t ParameterCount, TypeIndex ArgumentList)
Definition: TypeRecord.h:151
PrecompRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:933
PointerOptions
Equivalent to misc lfPointerAttr bitfields.
Definition: CodeView.h:354
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
MethodOverloadListRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:756
EndPrecompRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:950
int32_t getVFTableOffset() const
Definition: TypeRecord.h:738
UnionRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, uint64_t Size, StringRef Name, StringRef UniqueName)
Definition: TypeRecord.h:502
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
StaticDataMemberRecord(MemberAccess Access, TypeIndex Type, StringRef Name)
Definition: TypeRecord.h:817
TypeIndex getVTableShape() const
Definition: TypeRecord.h:490
CallingConvention CallConv
Definition: TypeRecord.h:165
MethodKind getMethodKind() const
Indicates if a method is defined with friend, virtual, static, etc.
Definition: TypeRecord.h:71
iterator end() const
Definition: ArrayRef.h:138
MemberAccess getAccess() const
Definition: TypeRecord.h:876
DataMemberRecord(MemberAccess Access, TypeIndex Type, uint64_t Offset, StringRef Name)
Definition: TypeRecord.h:793
HfaKind getHfa() const
Definition: TypeRecord.h:508
EnumeratorRecord(MemberAccess Access, APSInt Value, StringRef Name)
Definition: TypeRecord.h:838
TypeIndex getOverriddenVTable() const
Definition: TypeRecord.h:706
TypeRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:122
ArrayRef< OneMethodRecord > getMethods() const
Definition: TypeRecord.h:760
PointerMode
Equivalent to CV_ptrmode_e.
Definition: CodeView.h:345
VFTableShapeRecord(ArrayRef< VFTableSlotKind > Slots)
Definition: TypeRecord.h:558
A range adaptor for a pair of iterators.
ArrayRef< TypeIndex > getIndices() const
Definition: TypeRecord.h:259
uint8_t getBitOffset() const
Definition: TypeRecord.h:545
TypeIndex getDerivationList() const
Definition: TypeRecord.h:489
TypeIndex getParentScope() const
Definition: TypeRecord.h:619
MemberFuncIdRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:221
ClassRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:469
TypeIndex getCompleteClass() const
Definition: TypeRecord.h:705
MethodOptions
Equivalent to CV_fldattr_t bitfield.
Definition: CodeView.h:279
bool isVirtual() const
Is this method virtual.
Definition: TypeRecord.h:86
void setAttrs(PointerKind PK, PointerMode PM, PointerOptions PO, uint8_t Size)
Definition: TypeRecord.h:353
std::vector< OneMethodRecord > Methods
Definition: TypeRecord.h:762
TypeIndex getNestedType() const
Definition: TypeRecord.h:378
MemberFuncIdRecord(TypeIndex ClassType, TypeIndex FunctionType, StringRef Name)
Definition: TypeRecord.h:222
const GUID & getGuid() const
Definition: TypeRecord.h:586
VFTableShapeRecord(std::vector< VFTableSlotKind > Slots)
Definition: TypeRecord.h:560
StringRef getPrecompFilePath() const
Definition: TypeRecord.h:938
CallingConvention getCallConv() const
Definition: TypeRecord.h:159
Path to main source file, relative or absolute.
Definition: TypeRecord.h:682
detail::packed_endian_specific_integral< int32_t, little, unaligned > little32_t
Definition: Endian.h:278
VFTableShapeRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:557
ArrayRef< TypeIndex > getIndices() const
Definition: TypeRecord.h:245
StaticDataMemberRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:813
PointerOptions getOptions() const
Definition: TypeRecord.h:311
ArrayRecord(TypeIndex ElementType, TypeIndex IndexType, uint64_t Size, StringRef Name)
Definition: TypeRecord.h:401
uint32_t Size
Definition: Profile.cpp:47
TypeIndex getType() const
Definition: TypeRecord.h:859
FunctionOptions getOptions() const
Definition: TypeRecord.h:160
EnumeratorRecord(MemberAttributes Attrs, APSInt Value, StringRef Name)
Definition: TypeRecord.h:835
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition: CodeView.h:368
VFPtrRecord(TypeIndex Type)
Definition: TypeRecord.h:856
ProcedureRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:150
StringIdRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:599
uint16_t getParameterCount() const
Definition: TypeRecord.h:161
MemberAccess
Source-level access specifier. (CV_access_e)
Definition: CodeView.h:260
DataMemberRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:788
uint64_t getFieldOffset() const
Definition: TypeRecord.h:800
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MethodOptions getFlags() const
Get the flags that are not included in access control or method properties.
Definition: TypeRecord.h:79
std::vector< VFTableSlotKind > Slots
Definition: TypeRecord.h:572
BaseClassRecord(MemberAccess Access, TypeIndex Type, uint64_t Offset)
Definition: TypeRecord.h:872
ArrayRef< VFTableSlotKind > getSlots() const
Definition: TypeRecord.h:563
BaseClassRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:868
Equvalent to CV_fldattr_t in cvinfo.h.
Definition: TypeRecord.h:47
UnionRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:501
LLVM Value Representation.
Definition: Value.h:73
EnumRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:523
TypeRecordKind getKind() const
Definition: TypeRecord.h:125
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition: CodeView.h:173
uint32_t getStartTypeIndex() const
Definition: TypeRecord.h:935
VFPtrRecord(TypeRecordKind Kind)
Definition: TypeRecord.h:855
TypeIndex getModifiedType() const
Definition: TypeRecord.h:139
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
HfaKind getHfa() const
Definition: TypeRecord.h:477
bool containsNestedClass() const
Definition: TypeRecord.h:444
SmallVector< TypeIndex, MaxArgs > ArgIndices
Definition: TypeRecord.h:688
UdtModSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile, uint32_t LineNumber, uint16_t Module)
Definition: TypeRecord.h:651
MemberAccess getAccess() const
Get the access specifier. Valid for any kind of member.
Definition: TypeRecord.h:66
MemberPointerInfo(TypeIndex ContainingType, PointerToMemberRepresentation Representation)
Definition: TypeRecord.h:106
MemberAttributes(MemberAccess Access, MethodKind Kind, MethodOptions Flags)
Definition: TypeRecord.h:59
PointerToMemberRepresentation Representation
Definition: TypeRecord.h:116
StringRef getName() const
Definition: TypeRecord.h:708
ModifierOptions getModifiers() const
Definition: TypeRecord.h:140