Skip to content
Commit 885e6382 authored by Argyrios Kyrtzidis's avatar Argyrios Kyrtzidis
Browse files

Modifications to dyn_cast/cast to make them work for objects too, instead of only pointers.

The use case is if you have a wrapper class:

class Base {
  void *Ptr;
public:
  Base() : Ptr(0) { }
  operator bool() const { return Ptr; }
.....
}

and sub-wrappers that have exactly the same size:

class Sub : public Base {
public:
....
static bool classof(const Base*);
}

and in the code you would do:

void f(Base b) {
  Sub sub = dyn_cast<Sub>(b);
  if (sub) {
    ....
  }
}

llvm-svn: 78424
parent d9f95294
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment