[PATCH] Colored syntax highlighting for llvm-dwarfdump.

David Blaikie dblaikie at gmail.com
Tue Jan 6 00:15:06 PST 2015


On Mon, Jan 5, 2015 at 4:24 PM, Frederic Riss <friss at apple.com> wrote:

> REPOSITORY
>   rL LLVM
>
> ================
> Comment at: lib/DebugInfo/DWARFDebugInfoEntry.cpp:44-47
> @@ -41,2 +43,6 @@
>      uint32_t abbrCode = debug_info_data.getULEB128(&offset);
> +    {
> +      WithColor C(OS, syntax::Address);
> +      OS << format("\n0x%8.8x: ", Offset);
> +    }
>
> ----------------
> I'm not too fond of all the extra scopes, dunno what others think.
>
> If this could be implemented too look like:
> ```
> WithColor(OS, syntax::Address) << format("\n0x%8.8x: ", Offset);

```
> I think I'd prefer that (not sure if just adding a conversion operator
> from WithColor to raw_ostream would do the trick).
>

Alternatively you can (ab)use the comma operator with the existing scoped
device you have:

WithColor(OS, syntax::Address), OS << format(...)

But to remove the 'get' call and avoid the extra OS reference, you can
probably have "WithColor" return an object that's implicitly convertible to
ostream. (that does mean the op<< you then call must be a non-member
function (they shoudl be anyway, you might have to make some non-members
that are members))

I believe that should work...


>
> http://reviews.llvm.org/D6852
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150106/1a03b3a6/attachment.html>


More information about the llvm-commits mailing list