[PATCH] D103575: Allow signposts to take advantage of deferred string substitution

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 2 17:29:24 PDT 2021


aprantl created this revision.
aprantl added reviewers: JDevlieghere, dsanders, jroelofs.
Herald added subscribers: dexonsmith, hiraditya.
aprantl requested review of this revision.
Herald added a project: LLVM.

This is more an RFC at this point. I'm curious about feedback!

One nice feature of the os_signpost API is that format string substitutions happen in the consumer, not the logging application. LLVM's current Signpost class doesn't take advantage of this though and instead always uses a static `"Begin/End %s" ` format string.

This patch is proof of concept for how to use variadic macros to allow the API to be used as intended. Unfortunately, the primary use-case I had in mind (the `LLDB_SCOPED_TIMER()` macro) does not get much better from this, because `__PRETTY_FUNCTION__` is *not* a macro, but a static string, so signposts created by `LLDB_SCOPED_TIMER()` still use a static `"%s"` format string. At least `LLDB_SCOPED_TIMERF()` works as intended.


https://reviews.llvm.org/D103575

Files:
  lldb/include/lldb/Utility/Timer.h
  lldb/source/Utility/Timer.cpp
  lldb/unittests/Utility/TimerTest.cpp
  llvm/include/llvm/Support/Signposts.h
  llvm/lib/Support/Signposts.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103575.349421.patch
Type: text/x-patch
Size: 9583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210603/a453d3a3/attachment.bin>


More information about the llvm-commits mailing list