summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-28 09:10:16 +0000
committerChris Lattner <sabre@nondot.org>2009-12-28 09:10:16 +0000
commitd944cf76de128fbe8754703eacb3d5d4dee9ceda (patch)
tree86c3c00ae19975206cca20eb644c2559afa82c65 /llvm/lib/VMCore/Metadata.cpp
parent588096e51db7875b7aac8c61346dd97658f0e024 (diff)
downloadbcm5719-llvm-d944cf76de128fbe8754703eacb3d5d4dee9ceda.tar.gz
bcm5719-llvm-d944cf76de128fbe8754703eacb3d5d4dee9ceda.zip
avoid temporary CallbackVH's.
llvm-svn: 92218
Diffstat (limited to 'llvm/lib/VMCore/Metadata.cpp')
-rw-r--r--llvm/lib/VMCore/Metadata.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp
index c1213a3d3a9..2bf2c60f7ce 100644
--- a/llvm/lib/VMCore/Metadata.cpp
+++ b/llvm/lib/VMCore/Metadata.cpp
@@ -64,6 +64,11 @@ public:
MDNodeElement(Value *V, MDNode *P) : CallbackVH(V), Parent(P) {}
~MDNodeElement() {}
+ void set(Value *V, MDNode *P) {
+ setValPtr(V);
+ Parent = P;
+ }
+
virtual void deleted();
virtual void allUsesReplacedWith(Value *NV);
};
@@ -91,7 +96,7 @@ MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
Operands = new MDNodeElement[NumOperands];
MDNodeElement *Ptr = Operands;
for (unsigned i = 0; i != NumVals; ++i)
- Ptr[i] = MDNodeElement(Vals[i], this);
+ Ptr[i].set(Vals[i], this);
if (isFunctionLocal)
SubclassData |= FunctionLocalBit;
@@ -161,9 +166,8 @@ void MDNode::replaceElement(Value *From, Value *To) {
// Replace From element(s) in place.
for (SmallVector<unsigned, 4>::iterator I = Indexes.begin(), E = Indexes.end();
- I != E; ++I) {
- Operands[*I] = MDNodeElement(To, this);
- }
+ I != E; ++I)
+ Operands[*I].set(To, this);
// Insert updated "this" into the context's folding node set.
// If a node with same element list already exist then before inserting
OpenPOWER on IntegriCloud