LLVM 22.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
26
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();
76 return Session.getSymbolCache().findSymbolByTypeIndex(MPI.ContainingType);
77}
78
80 if (Record)
81 return Record->getSize();
82
83 switch (TI.getSimpleMode()) {
87 return 2;
90 return 4;
92 return 8;
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
159static inline bool isInheritanceKind(const MemberPointerInfo &MPI,
162 return (MPI.getRepresentation() == P1 || MPI.getRepresentation() == P2);
163}
164
173
182
191
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isInheritanceKind(const MemberPointerInfo &MPI, PointerToMemberRepresentation P1, PointerToMemberRepresentation P2)
PointerToMemberRepresentation getRepresentation() const
Definition TypeRecord.h:109
A 32-bit type reference.
Definition TypeIndex.h:97
NativeRawSymbol(NativeSession &PDBSession, PDB_SymType Tag, SymIndexId SymbolId)
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
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
std::optional< codeview::PointerRecord > Record
bool isRestrictedType() const override
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition CodeView.h:359
uint32_t SymIndexId
Definition PDBTypes.h:26
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition PDBExtras.h:51
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:243
LLVM_ABI void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, int Indent, const IPDBSession &Session, PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags)
This is an optimization pass for GlobalISel generic memory operations.
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:1869
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:851