[PATCH] D26477: Try to make ScopedPrinter use the new binary blob formatter

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 11:20:30 PST 2016


zturner added inline comments.


================
Comment at: lib/Support/raw_ostream.cpp:355
 
-raw_ostream &raw_ostream::operator<<(const FormattedHexBytes &FB) {
+raw_ostream &raw_ostream::operator<<(const FormattedBytes &FB) {
+  if (FB.Bytes.empty())
----------------
clayborg wrote:
> One thing that I was wondering is can we add an operator to the FormattedBytes class:
> 
> ```
> class FormattedBytes {
> public:
>     raw_ostream &operator<<(raw_ostream &s);
> };
> ```
> 
> And avoid this code being in raw_ostream.cpp? Seems wrong to put the implementation for dumping FormattedBytes into raw_ostream.cpp. Doesn't need to be done with this patch, but I found this not to be very C++.
> 
You might be interested in D25587.  My long term goal is to move away from all these overloaded operators entirely and be able to use printf-style formatting for everything.  You can imagine writing `OS << formatv("Bytes (Length={0}): ({1})", Data.size(), fmt_bytes(Data))`, for example.

When that happens, we'll be able to isolate the formatting code to more appropriate places.


https://reviews.llvm.org/D26477





More information about the llvm-commits mailing list