Fixes zealous MSVC static analyzers warnings (#3938)

Other unfixed as I'm not happy with caving to false positives of every analyzers.
This commit is contained in:
ocornut
2021-03-18 16:10:25 +01:00
parent 0c5b0c8b97
commit 412d6f7efe
3 changed files with 23 additions and 14 deletions

View File

@ -1133,11 +1133,18 @@ void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
if (InputQueueSurrogate != 0)
{
if ((c & 0xFC00) != 0xDC00) // Invalid low surrogate
{
InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID);
else if (IM_UNICODE_CODEPOINT_MAX == (0xFFFF)) // Codepoint will not fit in ImWchar (extra parenthesis around 0xFFFF somehow fixes -Wunreachable-code with Clang)
cp = IM_UNICODE_CODEPOINT_INVALID;
}
else
{
#if IM_UNICODE_CODEPOINT_MAX == 0xFFFF
cp = IM_UNICODE_CODEPOINT_INVALID; // Codepoint will not fit in ImWchar
#else
cp = (ImWchar)(((InputQueueSurrogate - 0xD800) << 10) + (c - 0xDC00) + 0x10000);
#endif
}
InputQueueSurrogate = 0;
}
InputQueueCharacters.push_back(cp);