summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/NativeEnumSymbol.cpp
blob: 38d65917306a7ef27bd56f53f209f1fc27728789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//===- NativeEnumSymbol.cpp - info about enum type --------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h"

#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"

#include <cassert>

using namespace llvm;
using namespace llvm::pdb;

NativeEnumSymbol::NativeEnumSymbol(NativeSession &Session, SymIndexId Id,
                                   const codeview::CVType &CVT)
    : NativeRawSymbol(Session, Id), CV(CVT),
      Record(codeview::TypeRecordKind::Enum) {
  assert(CV.kind() == codeview::TypeLeafKind::LF_ENUM);
  cantFail(visitTypeRecord(CV, *this));
}

NativeEnumSymbol::~NativeEnumSymbol() {}

std::unique_ptr<NativeRawSymbol> NativeEnumSymbol::clone() const {
  return llvm::make_unique<NativeEnumSymbol>(Session, SymbolId, CV);
}

std::unique_ptr<IPDBEnumSymbols>
NativeEnumSymbol::findChildren(PDB_SymType Type) const {
  switch (Type) {
  case PDB_SymType::Data: {
    // TODO(amccarth):  Provide an actual implementation.
    return nullptr;
  }
  default:
    return nullptr;
  }
}

Error NativeEnumSymbol::visitKnownRecord(codeview::CVType &CVR,
                                         codeview::EnumRecord &ER) {
  Record = ER;
  return Error::success();
}

Error NativeEnumSymbol::visitKnownMember(codeview::CVMemberRecord &CVM,
                                         codeview::EnumeratorRecord &R) {
  return Error::success();
}

PDB_SymType NativeEnumSymbol::getSymTag() const { return PDB_SymType::Enum; }

uint32_t NativeEnumSymbol::getClassParentId() const { return 0xFFFFFFFF; }

uint32_t NativeEnumSymbol::getUnmodifiedTypeId() const { return 0; }

bool NativeEnumSymbol::hasConstructor() const {
  return bool(Record.getOptions() &
              codeview::ClassOptions::HasConstructorOrDestructor);
}

bool NativeEnumSymbol::hasAssignmentOperator() const {
  return bool(Record.getOptions() &
              codeview::ClassOptions::HasOverloadedAssignmentOperator);
}

bool NativeEnumSymbol::hasCastOperator() const {
  return bool(Record.getOptions() &
              codeview::ClassOptions::HasConversionOperator);
}

uint64_t NativeEnumSymbol::getLength() const {
  const auto Id = Session.findSymbolByTypeIndex(Record.getUnderlyingType());
  const auto UnderlyingType =
      Session.getConcreteSymbolById<PDBSymbolTypeBuiltin>(Id);
  return UnderlyingType ? UnderlyingType->getLength() : 0;
}

std::string NativeEnumSymbol::getName() const { return Record.getName(); }

bool NativeEnumSymbol::isNested() const {
  return bool(Record.getOptions() & codeview::ClassOptions::Nested);
}

bool NativeEnumSymbol::hasOverloadedOperator() const {
  return bool(Record.getOptions() &
              codeview::ClassOptions::HasOverloadedOperator);
}

bool NativeEnumSymbol::isPacked() const {
  return bool(Record.getOptions() & codeview::ClassOptions::Packed);
}

bool NativeEnumSymbol::isScoped() const {
  return bool(Record.getOptions() & codeview::ClassOptions::Scoped);
}

uint32_t NativeEnumSymbol::getTypeId() const {
  return Session.findSymbolByTypeIndex(Record.getUnderlyingType());
}
OpenPOWER on IntegriCloud