@@ -199,7 +199,10 @@ class Pointer {
199
199
bool isField () const { return Base != 0 && Base != RootPtrMark; }
200
200
201
201
// / Accessor for information about the declaration site.
202
- const Descriptor *getDeclDesc () const { return Pointee->Desc ; }
202
+ const Descriptor *getDeclDesc () const {
203
+ assert (Pointee);
204
+ return Pointee->Desc ;
205
+ }
203
206
SourceLocation getDeclLoc () const { return getDeclDesc ()->getLocation (); }
204
207
205
208
// / Returns a pointer to the object of which this pointer is a field.
@@ -298,9 +301,15 @@ class Pointer {
298
301
// / Checks if the storage is extern.
299
302
bool isExtern () const { return Pointee && Pointee->isExtern (); }
300
303
// / Checks if the storage is static.
301
- bool isStatic () const { return Pointee->isStatic (); }
304
+ bool isStatic () const {
305
+ assert (Pointee);
306
+ return Pointee->isStatic ();
307
+ }
302
308
// / Checks if the storage is temporary.
303
- bool isTemporary () const { return Pointee->isTemporary (); }
309
+ bool isTemporary () const {
310
+ assert (Pointee);
311
+ return Pointee->isTemporary ();
312
+ }
304
313
// / Checks if the storage is a static temporary.
305
314
bool isStaticTemporary () const { return isStatic () && isTemporary (); }
306
315
@@ -323,7 +332,10 @@ class Pointer {
323
332
}
324
333
325
334
// / Returns the declaration ID.
326
- std::optional<unsigned > getDeclID () const { return Pointee->getDeclID (); }
335
+ std::optional<unsigned > getDeclID () const {
336
+ assert (Pointee);
337
+ return Pointee->getDeclID ();
338
+ }
327
339
328
340
// / Returns the byte offset from the start.
329
341
unsigned getByteOffset () const {
@@ -362,6 +374,7 @@ class Pointer {
362
374
// / Dereferences the pointer, if it's live.
363
375
template <typename T> T &deref () const {
364
376
assert (isLive () && " Invalid pointer" );
377
+ assert (Pointee);
365
378
if (isArrayRoot ())
366
379
return *reinterpret_cast <T *>(Pointee->rawData () + Base +
367
380
sizeof (InitMapPtr));
@@ -372,6 +385,7 @@ class Pointer {
372
385
// / Dereferences a primitive element.
373
386
template <typename T> T &elem (unsigned I) const {
374
387
assert (I < getNumElems ());
388
+ assert (Pointee);
375
389
return reinterpret_cast <T *>(Pointee->data () + sizeof (InitMapPtr))[I];
376
390
}
377
391
@@ -433,12 +447,14 @@ class Pointer {
433
447
// / Returns a descriptor at a given offset.
434
448
InlineDescriptor *getDescriptor (unsigned Offset) const {
435
449
assert (Offset != 0 && " Not a nested pointer" );
450
+ assert (Pointee);
436
451
return reinterpret_cast <InlineDescriptor *>(Pointee->rawData () + Offset) -
437
452
1 ;
438
453
}
439
454
440
455
// / Returns a reference to the InitMapPtr which stores the initialization map.
441
456
InitMapPtr &getInitMap () const {
457
+ assert (Pointee);
442
458
return *reinterpret_cast <InitMapPtr *>(Pointee->rawData () + Base);
443
459
}
444
460
0 commit comments