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

Commit
1 year ago
[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@gmail.com>
Author
Parents
Loading