[all-commits] [llvm/llvm-project] ca5ba2: [Support] Avoid warning about possibly uninitializ...

Sven Verdoolaege via All-commits all-commits at lists.llvm.org
Sat Jun 22 12:20:27 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca5ba2e46445caf2c8063a53eb6351fb596190e8
      https://github.com/llvm/llvm-project/commit/ca5ba2e46445caf2c8063a53eb6351fb596190e8
  Author: Sven Verdoolaege <sven at cerebras.net>
  Date:   2024-06-22 (Sat, 22 Jun 2024)

  Changed paths:
    M llvm/include/llvm/Support/FormatProviders.h

  Log Message:
  -----------
  [Support] Avoid warning about possibly uninitialized variable in format_provider (#95704)

The original implementation of HelperFunctions::consumeHexStyle always
sets Style when it returns true, but this is difficult for a compiler
to understand since it requires seeing that Str starts
with either an "x" or an "X" when starts_with_insensitive("x")
return true.
In particular, g++ 12 warns that HS may be used uninitialized
in the format_provider::format caller.

Change HelperFunctions::consumeHexStyle to return an optional
HexPrintStyle and to make the fact that Str necessarily starts
with an "X" when all other cases do not apply more explicit.
This helps both the compiler and the human reader of the code.

Co-authored-by: Sven Verdoolaege <sven.verdoolaege at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list