This patch adds a simple type that lets you create a functor from a function at compile time.
While working on Clang, I needed a way to create an llvm::filter_iterator that filters based on the dynamic type as determined by llvm::isa. As far as I'm aware, the best way to do this currently (without lambdas as they'd make the iterator type unutterable) is:
llvm::make_filter_range(MyRange, static_cast<bool(*)(Base *)>(&isa<Derived>))
That's problematic because the iterator object ends up storing a function pointer; if the compiler can't follow the iterator's path from creation to use then it probably won't be able to get round the unnecessary indirection. This new type solves that by storing the function address as part of the object type, so there's no runtime overhead.
I'd probably skip this extra generality of providing an extra predicate on top of the isa/dyn_cast filter. Users can implement that with another filtering iterator if needed.