LLVM  6.0.0svn
NativeEnumSymbol.cpp
Go to the documentation of this file.
1 //===- NativeEnumSymbol.cpp - info about enum type --------------*- 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 
11 
16 
17 #include <cassert>
18 
19 using namespace llvm;
20 using namespace llvm::pdb;
21 
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));
28 }
29 
31 
32 std::unique_ptr<NativeRawSymbol> NativeEnumSymbol::clone() const {
33  return llvm::make_unique<NativeEnumSymbol>(Session, SymbolId, CV);
34 }
35 
36 std::unique_ptr<IPDBEnumSymbols>
38  switch (Type) {
39  case PDB_SymType::Data: {
40  // TODO(amccarth): Provide an actual implementation.
41  return nullptr;
42  }
43  default:
44  return nullptr;
45  }
46 }
47 
50  Record = ER;
51  return Error::success();
52 }
53 
56  return Error::success();
57 }
58 
60 
61 uint32_t NativeEnumSymbol::getClassParentId() const { return 0xFFFFFFFF; }
62 
64 
66  return bool(Record.getOptions() &
68 }
69 
71  return bool(Record.getOptions() &
73 }
74 
76  return bool(Record.getOptions() &
78 }
79 
80 uint64_t NativeEnumSymbol::getLength() const {
81  const auto Id = Session.findSymbolByTypeIndex(Record.getUnderlyingType());
82  const auto UnderlyingType =
84  return UnderlyingType ? UnderlyingType->getLength() : 0;
85 }
86 
87 std::string NativeEnumSymbol::getName() const { return Record.getName(); }
88 
90  return bool(Record.getOptions() & codeview::ClassOptions::Nested);
91 }
92 
94  return bool(Record.getOptions() &
96 }
97 
99  return bool(Record.getOptions() & codeview::ClassOptions::Packed);
100 }
101 
103  return bool(Record.getOptions() & codeview::ClassOptions::Scoped);
104 }
105 
107  return Session.findSymbolByTypeIndex(Record.getUnderlyingType());
108 }
Error visitKnownRecord(codeview::CVType &CVR, codeview::EnumRecord &Record) override
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:688
Kind kind() const
Definition: CVRecord.h:37
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool hasAssignmentOperator() const override
StringRef getName() const
Definition: Record.cpp:1621
uint64_t getLength() const override
std::unique_ptr< IPDBEnumSymbols > findChildren(PDB_SymType Type) const override
std::unique_ptr< NativeRawSymbol > clone() const override
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx.
Definition: PDBTypes.h:162
TypeRecordKind
Distinguishes individual records in .debug$T section or PDB type stream.
Definition: CodeView.h:27
PDB_SymType getSymTag() const override
bool hasConstructor() const override
bool isPacked() const override
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
std::unique_ptr< T > getConcreteSymbolById(uint32_t SymbolId) const
Definition: IPDBSession.h:36
bool hasOverloadedOperator() const override
bool isNested() const override
Error visitTypeRecord(CVType &Record, TypeIndex Index, TypeVisitorCallbacks &Callbacks, VisitorDataSource Source=VDS_BytesPresent)
uint32_t getUnmodifiedTypeId() const override
uint32_t getClassParentId() const override
static ErrorSuccess success()
Create a success value.
Definition: Error.h:313
bool isScoped() const override
std::string getName() const override
bool hasCastOperator() const override
Error visitKnownMember(codeview::CVMemberRecord &CVM, codeview::EnumeratorRecord &Record) override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
NativeEnumSymbol(NativeSession &Session, SymIndexId Id, const codeview::CVType &CV)
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI)
uint32_t getTypeId() const override