LLVM 20.0.0git
Public Member Functions | Friends | List of all members
llvm::AssertingVH< ValueTy > Class Template Reference

Value handle that asserts if the Value is deleted. More...

#include "llvm/IR/ValueHandle.h"

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

Public Member Functions

 AssertingVH ()
 
 AssertingVH (ValueTy *P)
 
 AssertingVH (const AssertingVH &)=default
 
 operator ValueTy * () const
 
ValueTy * operator= (ValueTy *RHS)
 
ValueTy * operator= (const AssertingVH< ValueTy > &RHS)
 
ValueTy * operator-> () const
 
ValueTy & operator* () const
 

Friends

struct DenseMapInfo< AssertingVH< ValueTy > >
 

Detailed Description

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

Value handle that asserts if the Value is deleted.

This is a Value Handle that points to a value and asserts out if the value is destroyed while the handle is still live. This is very useful for catching dangling pointer bugs and other things which can be non-obvious. 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 an AssertingVH ensures that an assert is triggered as soon as the bad delete occurs.

Note that an AssertingVH handle does not follow values across RAUW operations. This means that RAUW's need to explicitly update the AssertingVH'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 260 of file ValueHandle.h.

Constructor & Destructor Documentation

◆ AssertingVH() [1/3]

template<typename ValueTy >
llvm::AssertingVH< ValueTy >::AssertingVH ( )
inline

Definition at line 288 of file ValueHandle.h.

◆ AssertingVH() [2/3]

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

Definition at line 289 of file ValueHandle.h.

◆ AssertingVH() [3/3]

template<typename ValueTy >
llvm::AssertingVH< ValueTy >::AssertingVH ( const AssertingVH< ValueTy > &  )
default

Member Function Documentation

◆ operator ValueTy *()

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

Definition at line 293 of file ValueHandle.h.

◆ operator*()

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

Definition at line 307 of file ValueHandle.h.

◆ operator->()

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

Definition at line 306 of file ValueHandle.h.

◆ operator=() [1/2]

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

Definition at line 301 of file ValueHandle.h.

References RHS.

◆ operator=() [2/2]

template<typename ValueTy >
ValueTy * llvm::AssertingVH< ValueTy >::operator= ( ValueTy *  RHS)
inline

Definition at line 297 of file ValueHandle.h.

References RHS.

Friends And Related Function Documentation

◆ DenseMapInfo< AssertingVH< ValueTy > >

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

Definition at line 239 of file ValueHandle.h.


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