LLVM  8.0.1
NativeTypePointer.cpp
Go to the documentation of this file.
1 //===- NativeTypePointer.cpp - info about pointer 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 
13 
14 #include <cassert>
15 
16 using namespace llvm;
17 using namespace llvm::codeview;
18 using namespace llvm::pdb;
19 
20 NativeTypePointer::NativeTypePointer(NativeSession &Session, SymIndexId Id,
22  : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI) {
23  assert(TI.isSimple());
24  assert(TI.getSimpleMode() != SimpleTypeMode::Direct);
25 }
26 
30  : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI),
31  Record(std::move(Record)) {}
32 
34 
36  PdbSymbolIdField ShowIdFields,
37  PdbSymbolIdField RecurseIdFields) const {
38  NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
39 
40  if (isMemberPointer()) {
41  dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
42  PdbSymbolIdField::ClassParent, ShowIdFields,
43  RecurseIdFields);
44  }
45  dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
46  PdbSymbolIdField::LexicalParent, ShowIdFields,
47  RecurseIdFields);
48  dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
49  PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
50  dumpSymbolField(OS, "length", getLength(), Indent);
51  dumpSymbolField(OS, "constType", isConstType(), Indent);
52  dumpSymbolField(OS, "isPointerToDataMember", isPointerToDataMember(), Indent);
53  dumpSymbolField(OS, "isPointerToMemberFunction", isPointerToMemberFunction(),
54  Indent);
55  dumpSymbolField(OS, "RValueReference", isRValueReference(), Indent);
56  dumpSymbolField(OS, "reference", isReference(), Indent);
57  dumpSymbolField(OS, "restrictedType", isRestrictedType(), Indent);
58  if (isMemberPointer()) {
59  if (isSingleInheritance())
60  dumpSymbolField(OS, "isSingleInheritance", 1, Indent);
61  else if (isMultipleInheritance())
62  dumpSymbolField(OS, "isMultipleInheritance", 1, Indent);
63  else if (isVirtualInheritance())
64  dumpSymbolField(OS, "isVirtualInheritance", 1, Indent);
65  }
66  dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
67  dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
68 }
69 
71  if (!isMemberPointer())
72  return 0;
73 
74  assert(Record);
75  const MemberPointerInfo &MPI = Record->getMemberInfo();
77 }
78 
79 uint64_t NativeTypePointer::getLength() const {
80  if (Record)
81  return Record->getSize();
82 
83  switch (TI.getSimpleMode()) {
84  case SimpleTypeMode::NearPointer:
85  case SimpleTypeMode::FarPointer:
86  case SimpleTypeMode::HugePointer:
87  return 2;
88  case SimpleTypeMode::NearPointer32:
89  case SimpleTypeMode::FarPointer32:
90  return 4;
91  case SimpleTypeMode::NearPointer64:
92  return 8;
93  case SimpleTypeMode::NearPointer128:
94  return 16;
95  default:
96  assert(false && "invalid simple type mode!");
97  }
98  return 0;
99 }
100 
102  // This is the pointee SymIndexId.
103  TypeIndex Referent = Record ? Record->ReferentType : TI.makeDirect();
104 
105  return Session.getSymbolCache().findSymbolByTypeIndex(Referent);
106 }
107 
109  if (!Record)
110  return false;
111  return Record->getMode() == PointerMode::LValueReference;
112 }
113 
115  if (!Record)
116  return false;
117  return Record->getMode() == PointerMode::RValueReference;
118 }
119 
121  if (!Record)
122  return false;
123  return Record->getMode() == PointerMode::PointerToDataMember;
124 }
125 
127  if (!Record)
128  return false;
129  return Record->getMode() == PointerMode::PointerToMemberFunction;
130 }
131 
133  if (!Record)
134  return false;
135  return (Record->getOptions() & PointerOptions::Const) != PointerOptions::None;
136 }
137 
139  if (!Record)
140  return false;
141  return (Record->getOptions() & PointerOptions::Restrict) !=
143 }
144 
146  if (!Record)
147  return false;
148  return (Record->getOptions() & PointerOptions::Volatile) !=
150 }
151 
153  if (!Record)
154  return false;
155  return (Record->getOptions() & PointerOptions::Unaligned) !=
157 }
158 
159 static inline bool isInheritanceKind(const MemberPointerInfo &MPI,
162  return (MPI.getRepresentation() == P1 || MPI.getRepresentation() == P2);
163 }
164 
166  if (!isMemberPointer())
167  return false;
168  return isInheritanceKind(
169  Record->getMemberInfo(),
170  PointerToMemberRepresentation::SingleInheritanceData,
171  PointerToMemberRepresentation::SingleInheritanceFunction);
172 }
173 
175  if (!isMemberPointer())
176  return false;
177  return isInheritanceKind(
178  Record->getMemberInfo(),
179  PointerToMemberRepresentation::MultipleInheritanceData,
180  PointerToMemberRepresentation::MultipleInheritanceFunction);
181 }
182 
184  if (!isMemberPointer())
185  return false;
186  return isInheritanceKind(
187  Record->getMemberInfo(),
188  PointerToMemberRepresentation::VirtualInheritanceData,
189  PointerToMemberRepresentation::VirtualInheritanceFunction);
190 }
191 
194 }
NativeTypePointer(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI)
uint64_t getLength() const override
TypeIndex makeDirect() const
Definition: TypeIndex.h:137
bool isUnalignedType() const override
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
SimpleTypeMode getSimpleMode() const
Definition: TypeIndex.h:132
Definition: BitVector.h:938
SymIndexId getTypeId() const override
A 32-bit type reference.
Definition: TypeIndex.h:96
Class to represent pointers.
Definition: DerivedTypes.h:467
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
PointerToMemberRepresentation getRepresentation() const
Definition: TypeRecord.h:116
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition: PDBExtras.h:49
void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, int Indent, const IPDBSession &Session, PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags)
Definition: PDBSymbol.cpp:186
bool isMultipleInheritance() const override
bool isRestrictedType() const override
SymIndexId getClassParentId() const override
bool isVirtualInheritance() const override
bool isReference() const override
bool isRValueReference() const override
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI)
static bool isInheritanceKind(const MemberPointerInfo &MPI, PointerToMemberRepresentation P1, PointerToMemberRepresentation P2)
SymbolCache & getSymbolCache()
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition: CodeView.h:368
bool isConstType() const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Definition: JSON.cpp:598
bool isVolatileType() const override
bool isSingleInheritance() const override
bool isPointerToDataMember() const override
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
bool isPointerToMemberFunction() const override
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override