[Lldb-commits] [PATCH] D27632: Add Formatv() versions of all our printf style formatting functions

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 9 13:47:05 PST 2016


zturner created this revision.
zturner added reviewers: labath, clayborg, jingham.
zturner added a subscriber: lldb-commits.

We have various functions like `Stream::Printf()`, and `Error::SetErrorStringWithFormat()`, `Log::Printf()`, and various others.  I added functions that delegate to `formatv` in case people want to see some actual usage in practice.

I also converted a few various Printfs, etc to this syntax just to demonstrate what it looks like.  I tried to find callsites that would illustrate how it makes things simpler, such as :

- not needing to call `.c_str()` and being able to pass `std::string` and/or `StringRef` directly as the argument.

- places where the same argument is printed multiple times, only having to pass it once (incidentally this fixed a spelling mistake since when passing the argument the 2nd time, there had been a typo.  So this also serves as an example of how this is safer than Printf, since less code typed = fewer chances to mess up).

- places where complex format strings are constructed, such as using the printf width specifier `*` or `PRIx64` are used and now we can simply pass whatever type we have directly, even if it's architecture dependent like `size_t`.

Various other uses.

Obviously a change like this is too big to do all in one pass, since it would have a roughly 100% chance of introducing new bugs and be impossible to bisect.  This is basically just to get the hookups in place and have a single-digit number of illustrative use cases.


https://reviews.llvm.org/D27632

Files:
  include/lldb/Core/Error.h
  include/lldb/Core/Log.h
  include/lldb/Core/ModuleSpec.h
  include/lldb/Core/Stream.h
  include/lldb/Interpreter/CommandReturnObject.h
  source/Breakpoint/BreakpointOptions.cpp
  source/Commands/CommandObjectApropos.cpp
  source/Core/Log.cpp
  source/Symbol/ClangASTContext.cpp
  source/Target/Target.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27632.80949.patch
Type: text/x-patch
Size: 12585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161209/4f191768/attachment.bin>


More information about the lldb-commits mailing list