Printable objects simply hold a function reference to a function that
does the printing. It allows the construction of Print helpers.
This would also be a good base to transform several MyClass::print(raw_ostream &OS, more arguments); function in llvm to a more C++-style interface (though I do not plan to do this refactoring myself at the moment).
Example:
Printable PrintLaneMask(unsigned LaneMask) {
return Printable([LaneMask](raw_ostream &OS) {
OS << format("%08X", LaneMask);
});
}
// Usage:
OS << PrintLaneMask(Mask);