[PATCH] [PATCH] Proposed alternative to llvm::format()

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Sep 18 12:48:37 PDT 2014


This looks really nice!

On 17 September 2014 22:34, kledzik at apple.com <kledzik at apple.com> wrote:
> Hi rafael, silvas,
>
> In using llvm::format() to dump columnar tables of data in my recent enhancements to llvm-objdump, I ran into some issues uncovered by the built bots that show how unsafe llvm::format() is.  The issues I hit where that the compiler did not check that %x match the integer size and that %s can match a StringRef but produce the wrong output.  %s is also ugly with StringRef values because you have to convert to a std::string then call c_str().
>
> All I really needed was a way to generate fixed with hexadecimal (e.g. 0x00001234) and fixed with strings (e.g. right or left justified strings in a column).  I whipped up an alternative that is easy to use with the stream operator and generates fixed with output.
>
> If there is interest in this, I can clean it up and add some test cases.  Or perhaps there already is some good technique for fixed width formatting.  This patch also contains examples changes in llvm-objdump to use this new functionality.
>
> http://reviews.llvm.org/D5390
>
> Files:
>   include/llvm/Support/Format.h
>   include/llvm/Support/raw_ostream.h
>   lib/Support/raw_ostream.cpp
>   tools/llvm-objdump/MachODump.cpp




More information about the llvm-commits mailing list