[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

Jacques Pienaar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 11:05:30 PDT 2021


jpienaar accepted this revision.
jpienaar added a comment.

Nice!



================
Comment at: llvm/lib/Support/Debug.cpp:84
 
 // -debug - Command line option to enable the DEBUG statements in the passes.
 // This flag may only be enabled in debug builds.
----------------
Would it make sense to have these above the flags instead of above the structs?


================
Comment at: llvm/lib/Support/Debug.cpp:96
 //until program termination.
-static cl::opt<unsigned>
-DebugBufferSize("debug-buffer-size",
-                cl::desc("Buffer the last N characters of debug output "
-                         "until program termination. "
-                         "[default 0 -- immediate print-out]"),
-                cl::Hidden,
-                cl::init(0));
+struct CreateDebugBufferSize {
+  static void *call() {
----------------
Why not in anonymous namespace too? (consistenly everywhere)


================
Comment at: llvm/lib/Support/DebugOptions.h:1
+//===-- DebugOptions.h - Global Command line options for libSupport  ------===//
+//
----------------
Missing c++?


================
Comment at: llvm/lib/Support/DebugOptions.h:30
+inline void initSupportOptions() {
+
+  initDebugCounterOptions();
----------------
rm?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105959/new/

https://reviews.llvm.org/D105959



More information about the llvm-commits mailing list