OSDN Git Service

Add two new classes: WeakVH and AssertingVH. These are both "ValueHandles",
authorChris Lattner <sabre@nondot.org>
Tue, 31 Mar 2009 22:11:05 +0000 (22:11 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 31 Mar 2009 22:11:05 +0000 (22:11 +0000)
commit722272df41d8de9c7683811b7bd8e901ee2f2785
tree1ef9fbc2d123af5224e5b2f5b2fb63b12b51c9dc
parentf385167b85abf9cb63a0bec94732d7185ee74e36
Add two new classes: WeakVH and AssertingVH.  These are both "ValueHandles",
which are effectively smart pointers to Value*'s.  They are both very light
weight and simple, and react to values being destroyed or being RAUW'd.

WeakVN does a best effort to follow a value around, including through RAUW
operations and will get nulled out of the value is destroyed.  This is useful
for the eventual "metadata that references a value" work, because it is a
reference to a value that does not show up on its use_* list.

AssertingVH is a pointer that compiles down to a dumb raw pointer when
assertions are disabled.  When enabled, it emits an assertion if the
pointed-to value is destroyed while it is still being referenced.  This
is very useful for Maps and other things, and should have caught the recent
bugs in CallGraph and Reassociate, for example.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68149 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/ValueHandle.h [new file with mode: 0644]
include/llvm/Value.h
lib/VMCore/Value.cpp