1 //===- NativeEnumSymbol.cpp - info about enum type --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h"
12 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
13 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
14 #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
20 using namespace llvm::pdb;
22 NativeEnumSymbol::NativeEnumSymbol(NativeSession &Session, SymIndexId Id,
23 const codeview::CVType &CVT)
24 : NativeRawSymbol(Session, Id), CV(CVT),
25 Record(codeview::TypeRecordKind::Enum) {
26 assert(CV.kind() == codeview::TypeLeafKind::LF_ENUM);
27 cantFail(visitTypeRecord(CV, *this));
30 NativeEnumSymbol::~NativeEnumSymbol() {}
32 std::unique_ptr<NativeRawSymbol> NativeEnumSymbol::clone() const {
33 return llvm::make_unique<NativeEnumSymbol>(Session, SymbolId, CV);
36 std::unique_ptr<IPDBEnumSymbols>
37 NativeEnumSymbol::findChildren(PDB_SymType Type) const {
39 case PDB_SymType::Data: {
40 // TODO(amccarth): Provide an actual implementation.
48 Error NativeEnumSymbol::visitKnownRecord(codeview::CVType &CVR,
49 codeview::EnumRecord &ER) {
51 return Error::success();
54 Error NativeEnumSymbol::visitKnownMember(codeview::CVMemberRecord &CVM,
55 codeview::EnumeratorRecord &R) {
56 return Error::success();
59 PDB_SymType NativeEnumSymbol::getSymTag() const { return PDB_SymType::Enum; }
61 uint32_t NativeEnumSymbol::getClassParentId() const { return 0xFFFFFFFF; }
63 uint32_t NativeEnumSymbol::getUnmodifiedTypeId() const { return 0; }
65 bool NativeEnumSymbol::hasConstructor() const {
66 return bool(Record.getOptions() &
67 codeview::ClassOptions::HasConstructorOrDestructor);
70 bool NativeEnumSymbol::hasAssignmentOperator() const {
71 return bool(Record.getOptions() &
72 codeview::ClassOptions::HasOverloadedAssignmentOperator);
75 bool NativeEnumSymbol::hasCastOperator() const {
76 return bool(Record.getOptions() &
77 codeview::ClassOptions::HasConversionOperator);
80 uint64_t NativeEnumSymbol::getLength() const {
81 const auto Id = Session.findSymbolByTypeIndex(Record.getUnderlyingType());
82 const auto UnderlyingType =
83 Session.getConcreteSymbolById<PDBSymbolTypeBuiltin>(Id);
84 return UnderlyingType ? UnderlyingType->getLength() : 0;
87 std::string NativeEnumSymbol::getName() const { return Record.getName(); }
89 bool NativeEnumSymbol::isNested() const {
90 return bool(Record.getOptions() & codeview::ClassOptions::Nested);
93 bool NativeEnumSymbol::hasOverloadedOperator() const {
94 return bool(Record.getOptions() &
95 codeview::ClassOptions::HasOverloadedOperator);
98 bool NativeEnumSymbol::isPacked() const {
99 return bool(Record.getOptions() & codeview::ClassOptions::Packed);
102 bool NativeEnumSymbol::isScoped() const {
103 return bool(Record.getOptions() & codeview::ClassOptions::Scoped);
106 uint32_t NativeEnumSymbol::getTypeId() const {
107 return Session.findSymbolByTypeIndex(Record.getUnderlyingType());