@@ -126,8 +126,19 @@ class WeakVH : public ValueHandleBase {
126
126
operator Value*() const {
127
127
return getValPtr ();
128
128
}
129
- };
130
-
129
+ };
130
+
131
+ // Specialize simplify_type to allow WeakVH to participate in
132
+ // dyn_cast, isa, etc.
133
+ template <typename From> struct simplify_type ;
134
+ template <> struct simplify_type <const WeakVH> {
135
+ typedef Value* SimpleType;
136
+ static SimpleType getSimplifiedValue (const WeakVH &WVH) {
137
+ return static_cast <Value *>(WVH);
138
+ }
139
+ };
140
+ template <> struct simplify_type <WeakVH> : public simplify_type<const WeakVH> {};
141
+
131
142
// / AssertingVH - This is a Value Handle that points to a value and asserts out
132
143
// / if the value is destroyed while the handle is still live. This is very
133
144
// / useful for catching dangling pointer bugs and other things which can be
@@ -188,6 +199,18 @@ class AssertingVH
188
199
ValueTy &operator *() const { return *getValPtr (); }
189
200
};
190
201
202
+ // Specialize simplify_type to allow AssertingVH to participate in
203
+ // dyn_cast, isa, etc.
204
+ template <typename From> struct simplify_type ;
205
+ template <> struct simplify_type <const AssertingVH<Value> > {
206
+ typedef Value* SimpleType;
207
+ static SimpleType getSimplifiedValue (const AssertingVH<Value> &AVH) {
208
+ return static_cast <Value *>(AVH);
209
+ }
210
+ };
211
+ template <> struct simplify_type <AssertingVH<Value> >
212
+ : public simplify_type<const AssertingVH<Value> > {};
213
+
191
214
// / CallbackVH - This is a value handle that allows subclasses to define
192
215
// / callbacks that run when the underlying Value has RAUW called on it or is
193
216
// / destroyed. This class can be used as the key of a map, as long as the user
@@ -232,6 +255,18 @@ class CallbackVH : public ValueHandleBase {
232
255
virtual void allUsesReplacedWith (Value *new_value) {}
233
256
};
234
257
258
+ // Specialize simplify_type to allow CallbackVH to participate in
259
+ // dyn_cast, isa, etc.
260
+ template <typename From> struct simplify_type ;
261
+ template <> struct simplify_type <const CallbackVH> {
262
+ typedef Value* SimpleType;
263
+ static SimpleType getSimplifiedValue (const CallbackVH &CVH) {
264
+ return static_cast <Value *>(CVH);
265
+ }
266
+ };
267
+ template <> struct simplify_type <CallbackVH>
268
+ : public simplify_type<const CallbackVH> {};
269
+
235
270
} // End llvm namespace
236
271
237
272
#endif
0 commit comments