LLVM  14.0.0git
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 {
55  return std::string(Record.Name);
56 }
57 
59  return Parent.getTypeId();
60 }
61 
64 }
65 
67  return PDB_LocType::Constant;
68 }
69 
70 bool NativeSymbolEnumerator::isConstType() const { return false; }
71 
72 bool NativeSymbolEnumerator::isVolatileType() const { return false; }
73 
74 bool NativeSymbolEnumerator::isUnalignedType() const { return false; }
75 
78 
79  switch (BT.getBuiltinType()) {
82  case PDB_BuiltinType::Char: {
83  assert(Record.Value.isSignedIntN(BT.getLength() * 8));
84  int64_t N = Record.Value.getSExtValue();
85  switch (BT.getLength()) {
86  case 1:
87  return Variant{static_cast<int8_t>(N)};
88  case 2:
89  return Variant{static_cast<int16_t>(N)};
90  case 4:
91  return Variant{static_cast<int32_t>(N)};
92  case 8:
93  return Variant{static_cast<int64_t>(N)};
94  }
95  break;
96  }
99  assert(Record.Value.isIntN(BT.getLength() * 8));
100  uint64_t U = Record.Value.getZExtValue();
101  switch (BT.getLength()) {
102  case 1:
103  return Variant{static_cast<uint8_t>(U)};
104  case 2:
105  return Variant{static_cast<uint16_t>(U)};
106  case 4:
107  return Variant{static_cast<uint32_t>(U)};
108  case 8:
109  return Variant{static_cast<uint64_t>(U)};
110  }
111  break;
112  }
113  case PDB_BuiltinType::Bool: {
114  assert(Record.Value.isIntN(BT.getLength() * 8));
115  uint64_t U = Record.Value.getZExtValue();
116  return Variant{static_cast<bool>(U)};
117  }
118  default:
119  assert(false && "Invalid enumeration type");
120  break;
121  }
122 
123  return Variant{Record.Value.getSExtValue()};
124 }
llvm::pdb::PDB_BuiltinType::ULong
@ ULong
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::pdb::PDB_BuiltinType::Char
@ Char
llvm::pdb::NativeSymbolEnumerator::getTypeId
SymIndexId getTypeId() const override
Definition: NativeSymbolEnumerator.cpp:58
llvm::pdb::NativeSymbolEnumerator::isUnalignedType
bool isUnalignedType() const override
Definition: NativeSymbolEnumerator.cpp:74
llvm::pdb::NativeSymbolEnumerator::getValue
Variant getValue() const override
Definition: NativeSymbolEnumerator.cpp:76
SymbolRecord.h
llvm::pdb::NativeSymbolEnumerator::Parent
const NativeTypeEnum & Parent
Definition: NativeSymbolEnumerator.h:43
llvm::pdb::PDB_DataKind::Constant
@ Constant
llvm::pdb::PdbSymbolIdField::Type
@ Type
llvm::pdb::NativeSymbolEnumerator::dump
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
Definition: NativeSymbolEnumerator.cpp:27
llvm::pdb::PDB_LocType
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:292
llvm::pdb::Bool
@ Bool
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
NativeSymbolEnumerator.h
llvm::pdb::PDB_SymType
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:243
llvm::pdb::NativeSymbolEnumerator::~NativeSymbolEnumerator
~NativeSymbolEnumerator() override
Definition: NativeSymbolEnumerator.cpp:25
llvm::pdb::PdbSymbolIdField::ClassParent
@ ClassParent
llvm::pdb::NativeSymbolEnumerator::getLocationType
PDB_LocType getLocationType() const override
Definition: NativeSymbolEnumerator.cpp:66
llvm::pdb::PDB_DataKind
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:228
llvm::pdb::PdbSymbolIdField::LexicalParent
@ LexicalParent
llvm::BitTracker
Definition: BitTracker.h:35
llvm::pdb::PDB_BuiltinType::Int
@ Int
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::pdb::NativeSymbolEnumerator::getClassParentId
SymIndexId getClassParentId() const override
Definition: NativeSymbolEnumerator.cpp:48
llvm::pdb::PDB_BuiltinType::UInt
@ UInt
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::pdb::NativeTypeEnum
Definition: NativeTypeEnum.h:23
llvm::codeview::EnumeratorRecord
Definition: TypeRecord.h:829
uint64_t
llvm::pdb::dumpSymbolField
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition: PDBExtras.h:47
llvm::pdb::dumpSymbolIdField
void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, int Indent, const IPDBSession &Session, PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags)
Definition: PDBSymbol.cpp:202
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::pdb::NativeSymbolEnumerator::getLexicalParentId
SymIndexId getLexicalParentId() const override
Definition: NativeSymbolEnumerator.cpp:52
llvm::Record
Definition: Record.h:1472
llvm::pdb::NativeRawSymbol::getSymIndexId
SymIndexId getSymIndexId() const override
Definition: NativeRawSymbol.cpp:292
llvm::pdb::NativeSymbolEnumerator::isVolatileType
bool isVolatileType() const override
Definition: NativeSymbolEnumerator.cpp:72
uint32_t
llvm::pdb::PDB_LocType::Constant
@ Constant
llvm::pdb::NativeTypeEnum::getTypeId
SymIndexId getTypeId() const override
Definition: NativeTypeEnum.cpp:340
llvm::pdb::Variant
Definition: PDBTypes.h:410
llvm::pdb::NativeSymbolEnumerator::getName
std::string getName() const override
Definition: NativeSymbolEnumerator.cpp:54
llvm::pdb::NativeTypeBuiltin
Definition: NativeTypeBuiltin.h:21
std
Definition: BitVector.h:838
uint16_t
llvm::pdb::NativeRawSymbol::dump
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
Definition: NativeRawSymbol.cpp:22
llvm::pdb::NativeSession
Definition: NativeSession.h:28
NativeTypeEnum.h
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::pdb::PdbSymbolIdField
PdbSymbolIdField
Definition: IPDBRawSymbol.h:24
llvm::pdb::PDB_BuiltinType::Long
@ Long
llvm::pdb::NativeSymbolEnumerator::isConstType
bool isConstType() const override
Definition: NativeSymbolEnumerator.cpp:70
llvm::pdb::NativeSymbolEnumerator::getDataKind
PDB_DataKind getDataKind() const override
Definition: NativeSymbolEnumerator.cpp:62
NativeTypeBuiltin.h
N
#define N
llvm::pdb::NativeRawSymbol::Session
NativeSession & Session
Definition: NativeRawSymbol.h:232
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:231
llvm::pdb::NativeTypeEnum::getUnderlyingBuiltinType
const NativeTypeBuiltin & getUnderlyingBuiltinType() const
Definition: NativeTypeEnum.cpp:375
llvm::pdb::NativeRawSymbol
Definition: NativeRawSymbol.h:21