From f7c4acef9915073388ec5cc36bc14fdb32def551 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 23 Aug 2003 19:43:16 +0000 Subject: [PATCH] Initial checkin of ValueHolder helper git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8072 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/ValueHolder.cpp | 16 ++++++++++++++++ support/lib/Support/ValueHolder.cpp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 lib/Support/ValueHolder.cpp create mode 100644 support/lib/Support/ValueHolder.cpp diff --git a/lib/Support/ValueHolder.cpp b/lib/Support/ValueHolder.cpp new file mode 100644 index 00000000000..e0806b538a3 --- /dev/null +++ b/lib/Support/ValueHolder.cpp @@ -0,0 +1,16 @@ +//===-- ValueHolder.cpp - Wrapper for Value implementation ----------------===// +// +// This class defines a simple subclass of User, which keeps a pointer to a +// Value, which automatically updates when Value::replaceAllUsesWith is called. +// This is useful when you have pointers to Value's in your pass, but the +// pointers get invalidated when some other portion of the algorithm is +// replacing Values with other Values. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/ValueHolder.h" +#include "llvm/Type.h" + +ValueHolder::ValueHolder(Value *V) : User(Type::TypeTy, Value::TypeVal) { + Operands.push_back(Use(V, this)); +} diff --git a/support/lib/Support/ValueHolder.cpp b/support/lib/Support/ValueHolder.cpp new file mode 100644 index 00000000000..e0806b538a3 --- /dev/null +++ b/support/lib/Support/ValueHolder.cpp @@ -0,0 +1,16 @@ +//===-- ValueHolder.cpp - Wrapper for Value implementation ----------------===// +// +// This class defines a simple subclass of User, which keeps a pointer to a +// Value, which automatically updates when Value::replaceAllUsesWith is called. +// This is useful when you have pointers to Value's in your pass, but the +// pointers get invalidated when some other portion of the algorithm is +// replacing Values with other Values. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/ValueHolder.h" +#include "llvm/Type.h" + +ValueHolder::ValueHolder(Value *V) : User(Type::TypeTy, Value::TypeVal) { + Operands.push_back(Use(V, this)); +}