[PATCH] D33899: Allow VersionPrinter to print to arbitrary raw_ostreams

Dimitry Andric via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 12:21:40 PDT 2017


dim added inline comments.


================
Comment at: include/llvm/Support/CommandLine.h:69
+typedef void (*VersionPrinterTy)(raw_ostream &);
+
 ///===---------------------------------------------------------------------===//
----------------
mehdi_amini wrote:
> Using a `std::function` (or maybe `llvm::function_ref`) would be allowing for more rich object to be passed in (i.e. a client that may want state to be passed around).
Maybe, but how would `VersionPrinter::print` or `VersionPrinter::operator=` know how to call that function object, and which parameters to pass?

In any case it looks like `llvm::function_ref` also doesn't support variable function types, you'd still need to settle on `function_ref<void(raw_ostream &)>` as 'the' type for version printing functions.  With `std::function` it seems to be the same.

The only advantage would maybe be the ownership of the function object, but I'm not sure if that is a big deal breaker in this case.  It's just for printing a version field. :)


https://reviews.llvm.org/D33899





More information about the llvm-commits mailing list