[llvm] [Support] Avoid warning about possibly uninitialized variable in format_provider (PR #95704)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 14:25:16 PDT 2024


================
@@ -132,11 +132,10 @@ struct format_provider<
 private:
 public:
   static void format(const T &V, llvm::raw_ostream &Stream, StringRef Style) {
-    HexPrintStyle HS;
     size_t Digits = 0;
-    if (consumeHexStyle(Style, HS)) {
-      Digits = consumeNumHexDigits(Style, HS, 0);
-      write_hex(Stream, V, HS, Digits);
+    if (const auto &HS = consumeHexStyle(Style)) {
----------------
dwblaikie wrote:

use non-ref (best to avoid reference lifetime extension) (and probably non-const, once it's local - there aren't many uses of local const in LLVM) here and below. Maybe name the type rather than using `auto`

https://github.com/llvm/llvm-project/pull/95704


More information about the llvm-commits mailing list