class PoisoningVH

Declaration

template <typename ValueTy>
class PoisoningVH { /* full declaration omitted */ };

Description

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 \c 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.

Declared at: llvm/include/llvm/IR/ValueHandle.h:445

Templates

ValueTy

Member Variables

private llvm::Value* ThePtr = nullptr

Method Overview

Methods

static llvm::Value* GetAsValue(llvm::Value* V)

Declared at: llvm/include/llvm/IR/ValueHandle.h:453

Parameters

llvm::Value* V

static llvm::Value* GetAsValue(
    const llvm::Value* V)

Declared at: llvm/include/llvm/IR/ValueHandle.h:454

Parameters

const llvm::Value* V

PoisoningVH<ValueTy>()

Declared at: llvm/include/llvm/IR/ValueHandle.h:497

PoisoningVH<ValueTy>(ValueTy* P)

Declared at: llvm/include/llvm/IR/ValueHandle.h:516

Parameters

ValueTy* P

llvm::Value* getRawValPtr() const

Declared at: llvm/include/llvm/IR/ValueHandle.h:484

ValueTy* getValPtr() const

Declared at: llvm/include/llvm/IR/ValueHandle.h:488

ValueTy* operator type - parameter - 0 -
    0 *() const

Declared at: llvm/include/llvm/IR/ValueHandle.h:519

void setRawValPtr(llvm::Value* P)

Declared at: llvm/include/llvm/IR/ValueHandle.h:485

Parameters

llvm::Value* P

void setValPtr(ValueTy* P)

Declared at: llvm/include/llvm/IR/ValueHandle.h:494

Parameters

ValueTy* P