LLVM  8.0.1
Public Member Functions | Friends | List of all members
llvm::PoisoningVH< ValueTy > Class Template Referencefinal

Value handle that poisons itself if the Value is deleted. More...

#include "llvm/IR/ValueHandle.h"

Inheritance diagram for llvm::PoisoningVH< ValueTy >:
Inheritance graph
[legend]
Collaboration diagram for llvm::PoisoningVH< ValueTy >:
Collaboration graph
[legend]

Public Member Functions

 PoisoningVH ()=default
 
 PoisoningVH (ValueTy *P)
 
 PoisoningVH (const PoisoningVH &RHS)
 
 ~PoisoningVH ()
 
PoisoningVHoperator= (const PoisoningVH &RHS)
 
 operator ValueTy * () const
 
ValueTy * operator-> () const
 
ValueTy & operator* () const
 
- Public Member Functions inherited from llvm::CallbackVH
 CallbackVH ()
 
 CallbackVH (Value *P)
 
 operator Value * () const
 
- Public Member Functions inherited from llvm::ValueHandleBase
 ValueHandleBase (HandleBaseKind Kind)
 
 ValueHandleBase (HandleBaseKind Kind, Value *V)
 
 ~ValueHandleBase ()
 
Valueoperator= (Value *RHS)
 
Valueoperator= (const ValueHandleBase &RHS)
 
Valueoperator-> () const
 
Valueoperator* () const
 

Friends

struct DenseMapInfo< PoisoningVH< ValueTy > >
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::ValueHandleBase
static void ValueIsDeleted (Value *V)
 
static void ValueIsRAUWd (Value *Old, Value *New)
 
- Protected Types inherited from llvm::ValueHandleBase
enum  HandleBaseKind { Assert, Callback, Weak, WeakTracking }
 This indicates what sub class the handle actually is. More...
 
- Protected Member Functions inherited from llvm::CallbackVH
 ~CallbackVH ()=default
 
 CallbackVH (const CallbackVH &)=default
 
CallbackVHoperator= (const CallbackVH &)=default
 
void setValPtr (Value *P)
 
- Protected Member Functions inherited from llvm::ValueHandleBase
 ValueHandleBase (const ValueHandleBase &RHS)
 
 ValueHandleBase (HandleBaseKind Kind, const ValueHandleBase &RHS)
 
ValuegetValPtr () const
 
void RemoveFromUseList ()
 Remove this ValueHandle from its current use list. More...
 
void clearValPtr ()
 Clear the underlying pointer without clearing the use list. More...
 
- Static Protected Member Functions inherited from llvm::ValueHandleBase
static bool isValid (Value *V)
 

Detailed Description

template<typename ValueTy>
class llvm::PoisoningVH< ValueTy >

Value handle that poisons itself if the Value is deleted.

This is a Value Handle that points to a value and poisons itself if the value is destroyed while the handle is still live. This is very useful for catching dangling pointer bugs where an AssertingVH cannot be used because the dangling handle needs to outlive the value without ever being used.

One particularly useful place to use this is as the Key of a map. Dangling pointer bugs often lead to really subtle bugs that only occur if another object happens to get allocated to the same address as the old one. Using a PoisoningVH ensures that an assert is triggered if looking up a new value in the map finds a handle from the old value.

Note that a PoisoningVH handle does not follow values across RAUW operations. This means that RAUW's need to explicitly update the PoisoningVH's as it moves. This is required because in non-assert mode this class turns into a trivial wrapper around a pointer.

Definition at line 450 of file ValueHandle.h.

Constructor & Destructor Documentation

◆ PoisoningVH() [1/3]

template<typename ValueTy>
llvm::PoisoningVH< ValueTy >::PoisoningVH ( )
default

◆ PoisoningVH() [2/3]

template<typename ValueTy>
llvm::PoisoningVH< ValueTy >::PoisoningVH ( ValueTy *  P)
inline

Definition at line 502 of file ValueHandle.h.

◆ PoisoningVH() [3/3]

template<typename ValueTy>
llvm::PoisoningVH< ValueTy >::PoisoningVH ( const PoisoningVH< ValueTy > &  RHS)
inline

Definition at line 503 of file ValueHandle.h.

◆ ~PoisoningVH()

template<typename ValueTy>
llvm::PoisoningVH< ValueTy >::~PoisoningVH ( )
inline

Definition at line 506 of file ValueHandle.h.

Member Function Documentation

◆ operator ValueTy *()

template<typename ValueTy>
llvm::PoisoningVH< ValueTy >::operator ValueTy * ( ) const
inline

Definition at line 522 of file ValueHandle.h.

References llvm::ValueHandleBase::getValPtr().

◆ operator*()

template<typename ValueTy>
ValueTy& llvm::PoisoningVH< ValueTy >::operator* ( ) const
inline

Definition at line 525 of file ValueHandle.h.

◆ operator->()

template<typename ValueTy>
ValueTy* llvm::PoisoningVH< ValueTy >::operator-> ( ) const
inline

Definition at line 524 of file ValueHandle.h.

◆ operator=()

template<typename ValueTy>
PoisoningVH& llvm::PoisoningVH< ValueTy >::operator= ( const PoisoningVH< ValueTy > &  RHS)
inline

Definition at line 511 of file ValueHandle.h.

Friends And Related Function Documentation

◆ DenseMapInfo< PoisoningVH< ValueTy > >

template<typename ValueTy>
friend struct DenseMapInfo< PoisoningVH< ValueTy > >
friend

Definition at line 455 of file ValueHandle.h.


The documentation for this class was generated from the following file: