LLVM  8.0.1
NativeSymbolEnumerator.cpp
Go to the documentation of this file.
1 //===- NativeSymbolEnumerator.cpp - info about enumerators ------*- 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 
15 
16 using namespace llvm;
17 using namespace llvm::codeview;
18 using namespace llvm::pdb;
19 
20 NativeSymbolEnumerator::NativeSymbolEnumerator(
21  NativeSession &Session, SymIndexId Id, const NativeTypeEnum &Parent,
23  : NativeRawSymbol(Session, PDB_SymType::Data, Id), Parent(Parent),
24  Record(std::move(Record)) {}
25 
27 
29  PdbSymbolIdField ShowIdFields,
30  PdbSymbolIdField RecurseIdFields) const {
31  NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
32  dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
33  PdbSymbolIdField::ClassParent, ShowIdFields,
34  RecurseIdFields);
35  dumpSymbolIdField(OS, "lexicalParentId", getLexicalParentId(), Indent,
37  RecurseIdFields);
38  dumpSymbolField(OS, "name", getName(), Indent);
39  dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
40  PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
41  dumpSymbolField(OS, "dataKind", getDataKind(), Indent);
42  dumpSymbolField(OS, "locationType", getLocationType(), Indent);
43  dumpSymbolField(OS, "constType", isConstType(), Indent);
44  dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
45  dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
46  dumpSymbolField(OS, "value", getValue(), Indent);
47 }
48 
50  return Parent.getSymIndexId();
51 }
52 
54 
55 std::string NativeSymbolEnumerator::getName() const { return Record.Name; }
56 
58  return Parent.getTypeId();
59 }
60 
63 }
64 
66  return PDB_LocType::Constant;
67 }
68 
69 bool NativeSymbolEnumerator::isConstType() const { return false; }
70 
71 bool NativeSymbolEnumerator::isVolatileType() const { return false; }
72 
73 bool NativeSymbolEnumerator::isUnalignedType() const { return false; }
74 
77 
78  switch (BT.getBuiltinType()) {
81  case PDB_BuiltinType::Char: {
82  assert(Record.Value.isSignedIntN(BT.getLength() * 8));
83  int64_t N = Record.Value.getSExtValue();
84  switch (BT.getLength()) {
85  case 1:
86  return Variant{static_cast<int8_t>(N)};
87  case 2:
88  return Variant{static_cast<int16_t>(N)};
89  case 4:
90  return Variant{static_cast<int32_t>(N)};
91  case 8:
92  return Variant{static_cast<int64_t>(N)};
93  }
94  break;
95  }
98  assert(Record.Value.isIntN(BT.getLength() * 8));
99  uint64_t U = Record.Value.getZExtValue();
100  switch (BT.getLength()) {
101  case 1:
102  return Variant{static_cast<uint8_t>(U)};
103  case 2:
104  return Variant{static_cast<uint16_t>(U)};
105  case 4:
106  return Variant{static_cast<uint32_t>(U)};
107  case 8:
108  return Variant{static_cast<uint64_t>(U)};
109  }
110  break;
111  }
112  case PDB_BuiltinType::Bool: {
113  assert(Record.Value.isIntN(BT.getLength() * 8));
114  uint64_t U = Record.Value.getZExtValue();
115  return Variant{static_cast<bool>(U)};
116  }
117  default:
118  assert(false && "Invalid enumeration type");
119  break;
120  }
121 
122  return Variant{Record.Value.getSExtValue()};
123 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
PDB_LocType getLocationType() const override
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
const NativeTypeBuiltin & getUnderlyingBuiltinType() const
SymIndexId getTypeId() const override
Definition: BitVector.h:938
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:183
SymIndexId getSymIndexId() const override
SymIndexId getLexicalParentId() const override
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx.
Definition: PDBTypes.h:168
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition: PDBExtras.h:49
uint64_t getLength() const override
void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, int Indent, const IPDBSession &Session, PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags)
Definition: PDBSymbol.cpp:186
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:232
PDB_BuiltinType getBuiltinType() const override
SymIndexId getClassParentId() const override
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
std::string getName() const override
#define N
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Definition: JSON.cpp:598
PDB_DataKind getDataKind() const override
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
SymIndexId getTypeId() const override