LLVM  10.0.0svn
NativeSymbolEnumerator.cpp
Go to the documentation of this file.
1 //===- NativeSymbolEnumerator.cpp - info about enumerators ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
14 
15 using namespace llvm;
16 using namespace llvm::codeview;
17 using namespace llvm::pdb;
18 
19 NativeSymbolEnumerator::NativeSymbolEnumerator(
20  NativeSession &Session, SymIndexId Id, const NativeTypeEnum &Parent,
22  : NativeRawSymbol(Session, PDB_SymType::Data, Id), Parent(Parent),
23  Record(std::move(Record)) {}
24 
26 
28  PdbSymbolIdField ShowIdFields,
29  PdbSymbolIdField RecurseIdFields) const {
30  NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
31  dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
32  PdbSymbolIdField::ClassParent, ShowIdFields,
33  RecurseIdFields);
34  dumpSymbolIdField(OS, "lexicalParentId", getLexicalParentId(), Indent,
36  RecurseIdFields);
37  dumpSymbolField(OS, "name", getName(), Indent);
38  dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
39  PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
40  dumpSymbolField(OS, "dataKind", getDataKind(), Indent);
41  dumpSymbolField(OS, "locationType", getLocationType(), Indent);
42  dumpSymbolField(OS, "constType", isConstType(), Indent);
43  dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
44  dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
45  dumpSymbolField(OS, "value", getValue(), Indent);
46 }
47 
49  return Parent.getSymIndexId();
50 }
51 
53 
54 std::string NativeSymbolEnumerator::getName() const { return Record.Name; }
55 
57  return Parent.getTypeId();
58 }
59 
62 }
63 
65  return PDB_LocType::Constant;
66 }
67 
68 bool NativeSymbolEnumerator::isConstType() const { return false; }
69 
70 bool NativeSymbolEnumerator::isVolatileType() const { return false; }
71 
72 bool NativeSymbolEnumerator::isUnalignedType() const { return false; }
73 
76 
77  switch (BT.getBuiltinType()) {
80  case PDB_BuiltinType::Char: {
81  assert(Record.Value.isSignedIntN(BT.getLength() * 8));
82  int64_t N = Record.Value.getSExtValue();
83  switch (BT.getLength()) {
84  case 1:
85  return Variant{static_cast<int8_t>(N)};
86  case 2:
87  return Variant{static_cast<int16_t>(N)};
88  case 4:
89  return Variant{static_cast<int32_t>(N)};
90  case 8:
91  return Variant{static_cast<int64_t>(N)};
92  }
93  break;
94  }
97  assert(Record.Value.isIntN(BT.getLength() * 8));
98  uint64_t U = Record.Value.getZExtValue();
99  switch (BT.getLength()) {
100  case 1:
101  return Variant{static_cast<uint8_t>(U)};
102  case 2:
103  return Variant{static_cast<uint16_t>(U)};
104  case 4:
105  return Variant{static_cast<uint32_t>(U)};
106  case 8:
107  return Variant{static_cast<uint64_t>(U)};
108  }
109  break;
110  }
111  case PDB_BuiltinType::Bool: {
112  assert(Record.Value.isIntN(BT.getLength() * 8));
113  uint64_t U = Record.Value.getZExtValue();
114  return Variant{static_cast<bool>(U)};
115  }
116  default:
117  assert(false && "Invalid enumeration type");
118  break;
119  }
120 
121  return Variant{Record.Value.getSExtValue()};
122 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:937
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:241
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:226
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition: PDBExtras.h:48
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:185
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:290
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())
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:45
SymIndexId getTypeId() const override