• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- MethodListRecordBuilder.cpp ---------------------------------------===//
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 #include "llvm/DebugInfo/CodeView/MethodListRecordBuilder.h"
11 #include "llvm/DebugInfo/CodeView/FieldListRecordBuilder.h"
12 
13 using namespace llvm;
14 using namespace codeview;
15 
MethodListRecordBuilder()16 MethodListRecordBuilder::MethodListRecordBuilder()
17     : ListRecordBuilder(TypeRecordKind::MethodOverloadList) {}
18 
writeMethod(MemberAccess Access,MethodKind Kind,MethodOptions Options,TypeIndex Type,int32_t VTableSlotOffset)19 void MethodListRecordBuilder::writeMethod(MemberAccess Access, MethodKind Kind,
20                                           MethodOptions Options, TypeIndex Type,
21                                           int32_t VTableSlotOffset) {
22   TypeRecordBuilder &Builder = getBuilder();
23 
24   uint16_t Flags = static_cast<uint16_t>(Access);
25   Flags |= static_cast<uint16_t>(Kind) << MethodKindShift;
26   Flags |= static_cast<uint16_t>(Options);
27 
28   Builder.writeUInt16(Flags);
29   Builder.writeUInt16(0);
30   Builder.writeTypeIndex(Type);
31   switch (Kind) {
32   case MethodKind::IntroducingVirtual:
33   case MethodKind::PureIntroducingVirtual:
34     assert(VTableSlotOffset >= 0);
35     Builder.writeInt32(VTableSlotOffset);
36     break;
37 
38   default:
39     assert(VTableSlotOffset == -1);
40     break;
41   }
42 
43   // TODO: Fail if too big?
44 }
45 
writeMethod(const MethodInfo & Method)46 void MethodListRecordBuilder::writeMethod(const MethodInfo &Method) {
47   writeMethod(Method.getAccess(), Method.getKind(), Method.getOptions(),
48               Method.getType(), Method.getVTableSlotOffset());
49 }
50