26 :
Pointer(Pointee, Pointee->getDescriptor()->getMetadataSize(),
27 Pointee->getDescriptor()->getMetadataSize()) {}
30 :
Pointer(Pointee, BaseAndOffset, BaseAndOffset) {}
33 : Offset(
P.Offset), PointeeStorage(
P.PointeeStorage),
34 StorageKind(
P.StorageKind) {
37 PointeeStorage.BS.Pointee->addPointer(
this);
42 assert((
Base == RootPtrMark ||
Base %
alignof(
void *) == 0) &&
"wrong base");
44 PointeeStorage.BS = {Pointee,
Base};
47 Pointee->addPointer(
this);
51 : Offset(
P.Offset), PointeeStorage(
P.PointeeStorage),
52 StorageKind(
P.StorageKind) {
55 PointeeStorage.BS.Pointee->replacePointer(&
P,
this);
62 if (
Block *Pointee = PointeeStorage.BS.Pointee) {
63 Pointee->removePointer(
this);
64 PointeeStorage.BS.Pointee =
nullptr;
73 if (
P.isBlockPointer() && this->block() ==
P.block()) {
75 PointeeStorage.BS.Base =
P.PointeeStorage.BS.Base;
79 if (
Block *Pointee = PointeeStorage.BS.Pointee) {
80 Pointee->removePointer(
this);
81 PointeeStorage.BS.Pointee =
nullptr;
86 StorageKind =
P.StorageKind;
89 if (
P.isBlockPointer()) {
90 PointeeStorage.BS =
P.PointeeStorage.BS;
91 PointeeStorage.BS.Pointee =
P.PointeeStorage.BS.Pointee;
93 if (PointeeStorage.BS.Pointee)
94 PointeeStorage.BS.Pointee->addPointer(
this);
95 }
else if (
P.isIntegralPointer()) {
96 PointeeStorage.Int =
P.PointeeStorage.Int;
97 }
else if (
P.isFunctionPointer()) {
98 PointeeStorage.Fn =
P.PointeeStorage.Fn;
99 }
else if (
P.isTypeidPointer()) {
100 PointeeStorage.Typeid =
P.PointeeStorage.Typeid;
102 assert(
false &&
"Unhandled storage kind");
110 if (
P.isBlockPointer() && this->block() ==
P.block()) {
112 PointeeStorage.BS.Base =
P.PointeeStorage.BS.Base;
116 if (
Block *Pointee = PointeeStorage.BS.Pointee) {
117 assert(
P.block() != this->block());
118 Pointee->removePointer(
this);
119 PointeeStorage.BS.Pointee =
nullptr;
124 StorageKind =
P.StorageKind;
127 if (
P.isBlockPointer()) {
128 PointeeStorage.BS =
P.PointeeStorage.BS;
129 PointeeStorage.BS.Pointee =
P.PointeeStorage.BS.Pointee;
131 if (PointeeStorage.BS.Pointee)
132 PointeeStorage.BS.Pointee->addPointer(
this);
133 }
else if (
P.isIntegralPointer()) {
134 PointeeStorage.Int =
P.PointeeStorage.Int;
135 }
else if (
P.isFunctionPointer()) {
136 PointeeStorage.Fn =
P.PointeeStorage.Fn;
137 }
else if (
P.isTypeidPointer()) {
138 PointeeStorage.Typeid =
P.PointeeStorage.Typeid;
140 assert(
false &&
"Unhandled storage kind");
171 else if (
const auto *
E = Desc->
asExpr()) {
173 if (
const auto *NewExpr = dyn_cast<CXXNewExpr>(
E)) {
175 if (NewExpr->isArray()) {
183 AllocatedType = NewExpr->getAllocatedType();
187 static int ReportedDynamicAllocs = 0;
194 llvm_unreachable(
"Invalid allocation type");
205 if (FD->getParent()->isInvalidDecl())
208 unsigned FieldIndex = FD->getFieldIndex();
248 bool IsVirtual =
false;
252 if (
const auto *BaseOrMember = Desc->
asDecl()) {
253 if (
const auto *FD = dyn_cast<FieldDecl>(BaseOrMember)) {
256 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(BaseOrMember)) {
262 cast<CXXRecordDecl>(BaseRecord->
getDecl()));
274 llvm_unreachable(
"Invalid field type");
282 std::reverse(
Path.begin(),
Path.end());
289 switch (StorageKind) {
291 const Block *B = PointeeStorage.BS.Pointee;
292 OS <<
"(Block) " << B <<
" {";
295 OS <<
"rootptr(" << PointeeStorage.BS.Base <<
"), ";
297 OS << PointeeStorage.BS.Base <<
", ";
302 OS << Offset <<
", ";
312 OS << PointeeStorage.Int.Value <<
" + " << Offset <<
", "
313 << PointeeStorage.Int.Desc;
345 assert(PointeeStorage.BS.Pointee &&
346 "Cannot check if null pointer was initialized");
350 if (
isStatic() && PointeeStorage.BS.Base == 0)
361 return IM->second->isElementInitialized(
getIndex());
375 assert(PointeeStorage.BS.Pointee &&
"Cannot initialize null pointer");