LLVM 20.0.0git
NativeTypePointer.cpp
Go to the documentation of this file.
1//===- NativeTypePointer.cpp - info about pointer type ----------*- 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
11
13
14#include <cassert>
15
16using namespace llvm;
17using namespace llvm::codeview;
18using namespace llvm::pdb;
19
22 : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI) {
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,
43 RecurseIdFields);
44 }
45 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
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()) {
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
75 const MemberPointerInfo &MPI = Record->getMemberInfo();
77}
78
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
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) !=
142 PointerOptions::None;
143}
144
146 if (!Record)
147 return false;
148 return (Record->getOptions() & PointerOptions::Volatile) !=
149 PointerOptions::None;
150}
151
153 if (!Record)
154 return false;
155 return (Record->getOptions() & PointerOptions::Unaligned) !=
156 PointerOptions::None;
157}
158
159static 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}
static bool isInheritanceKind(const MemberPointerInfo &MPI, PointerToMemberRepresentation P1, PointerToMemberRepresentation P2)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
Class to represent pointers.
Definition: DerivedTypes.h:646
PointerToMemberRepresentation getRepresentation() const
Definition: TypeRecord.h:109
A 32-bit type reference.
Definition: TypeIndex.h:96
SimpleTypeMode getSimpleMode() const
Definition: TypeIndex.h:141
TypeIndex makeDirect() const
Definition: TypeIndex.h:146
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
SymbolCache & getSymbolCache()
SymIndexId getTypeId() const override
bool isPointerToDataMember() const override
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
bool isPointerToMemberFunction() const override
SymIndexId getClassParentId() const override
bool isReference() const override
bool isVirtualInheritance() const override
bool isConstType() const override
bool isSingleInheritance() const override
bool isMultipleInheritance() const override
bool isRValueReference() const override
NativeTypePointer(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI)
bool isUnalignedType() const override
bool isVolatileType() const override
uint64_t getLength() const override
bool isRestrictedType() const override
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI) const
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition: CodeView.h:386
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition: PDBExtras.h:47
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:243
void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, int Indent, const IPDBSession &Session, PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags)
Definition: PDBSymbol.cpp:202
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:1856
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858