Skip to content

Commit

Permalink
Compensate for new warnings and STL changes in VS 16.7 (#7319)
Browse files Browse the repository at this point in the history
New warnings were added in VS 16.7 and `std::map::erase` is now `noexcept`.
Update our code to be compatible with the new enforcement.

## PR Checklist
* [x] Closes broken audit in main after Agents updated over the weekend.
* [x] I work here.
* [x] Audit mode passes now
* [x] Am core contributor.

## Validation Steps Performed
* [x] Ran audit mode locally

(cherry picked from commit a50c48c)
  • Loading branch information
miniksa authored and DHowett committed Aug 20, 2020
1 parent 33a1a11 commit b7e4fb1
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/buffer/out/UnicodeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ void UnicodeStorage::StoreGlyph(const key_type key, const mapped_type& glyph)
// - erases key and its associated data from the storage
// Arguments:
// - key - the key to remove
// ~~~~~~~~~~~~~~
// NOTE: VS 16.7 changes std::map::erase to noexcept, but the build agents are still 16.6.5.
// Ignore this audit warning on your dev box until the build starts failing. Then fix it
// and remove this comment.
// ~~~~~~~~~~~~~
void UnicodeStorage::Erase(const key_type key)
{
_map.erase(key);
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/PublicTerminalCore/HwndTerminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ try
case WM_RBUTTONUP:
ReleaseCapture();
break;
default:
break;
}

// Suppress all mouse events that made it into the terminal.
Expand Down Expand Up @@ -132,6 +134,8 @@ try
terminal->_hwnd.release();
terminal->Teardown();
return 0;
default:
break;
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalConnection/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD reason, LPVOID /*reserved*/)
TraceLoggingUnregister(g_hTerminalConnectionProvider);
}
break;
default:
break;
}

return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion src/inc/til/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"

// Copy any regions that overlap from this map to the new one.
// Just iterate our runs...
for (const auto run : *this)
for (const auto& run : *this)
{
// intersect them with the new map
// so we don't attempt to set bits that fit outside
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dx/DxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ try
// Use a transform by the size of one cell to convert cells-to-pixels
// as we clear.
_d2dDeviceContext->SetTransform(D2D1::Matrix3x2F::Scale(_glyphCell));
for (const auto rect : _invalidMap.runs())
for (const auto& rect : _invalidMap.runs())
{
// Use aliased.
// For graphics reasons, it'll look better because it will ensure that
Expand Down
6 changes: 6 additions & 0 deletions src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,9 @@ bool AdaptDispatch::TabClear(const size_t clearType)
case DispatchTypes::TabClearType::ClearAllColumns:
success = _ClearAllTabStops();
break;
default:
success = false;
break;
}
return success;
}
Expand Down Expand Up @@ -1695,6 +1698,9 @@ bool AdaptDispatch::DesignateCodingSystem(const wchar_t codingSystem)
_termOutput.EnableGrTranslation(false);
}
break;
default:
success = false;
break;
}
return success;
}
Expand Down
9 changes: 6 additions & 3 deletions src/terminal/adapter/terminalOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ bool TerminalOutput::Designate94Charset(size_t gsetNumber, const std::pair<wchar
return _SetTranslationTable(gsetNumber, DecCyrillic);
case L'5': // Russian NRCS
return _SetTranslationTable(gsetNumber, RussianNrcs);
default:
return false;
}
return false;
case L'"':
switch (charset.second)
{
Expand All @@ -77,8 +78,9 @@ bool TerminalOutput::Designate94Charset(size_t gsetNumber, const std::pair<wchar
return _SetTranslationTable(gsetNumber, GreekNrcs);
case L'4': // DEC Hebrew
return _SetTranslationTable(gsetNumber, DecHebrew);
default:
return false;
}
return false;
case L'%':
switch (charset.second)
{
Expand All @@ -92,8 +94,9 @@ bool TerminalOutput::Designate94Charset(size_t gsetNumber, const std::pair<wchar
return _SetTranslationTable(gsetNumber, DecSupplemental);
case L'6': // Portuguese NRCS
return _SetTranslationTable(gsetNumber, PortugueseNrcs);
default:
return false;
}
return false;
default:
return false;
}
Expand Down
22 changes: 14 additions & 8 deletions src/terminal/input/mouseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ static constexpr std::wstring_view ApplicationDownSequence{ L"\x1bOB" };
// - true iff button is a button message to translate
static constexpr bool _isButtonMsg(const unsigned int button) noexcept
{
bool isButton = false;
switch (button)
{
case WM_LBUTTONDBLCLK:
Expand All @@ -43,10 +42,10 @@ static constexpr bool _isButtonMsg(const unsigned int button) noexcept
case WM_MBUTTONDBLCLK:
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
isButton = true;
break;
return true;
default:
return false;
}
return isButton;
}

// Routine Description:
Expand Down Expand Up @@ -80,7 +79,6 @@ static constexpr bool _isWheelMsg(const unsigned int buttonCode) noexcept
// - true iff button is a button down event
static constexpr bool _isButtonDown(const unsigned int button) noexcept
{
bool isButtonDown = false;
switch (button)
{
case WM_LBUTTONDBLCLK:
Expand All @@ -91,10 +89,10 @@ static constexpr bool _isButtonDown(const unsigned int button) noexcept
case WM_MBUTTONDBLCLK:
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
isButtonDown = true;
break;
return true;
default:
return false;
}
return isButtonDown;
}

// Routine Description:
Expand Down Expand Up @@ -180,6 +178,10 @@ static constexpr int _windowsButtonToXEncoding(const unsigned int button,
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
xvalue = delta > 0 ? 0x40 : 0x41;
break;
default:
xvalue = 0;
break;
}
if (isHover)
{
Expand Down Expand Up @@ -235,6 +237,10 @@ static constexpr int _windowsButtonToSGREncoding(const unsigned int button,
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
xvalue = delta > 0 ? 0x40 : 0x41;
break;
default:
xvalue = 0;
break;
}
if (isHover)
{
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/input/terminalInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static bool _searchWithModifier(const KeyEvent& keyEvent, InputSender sender)
{ s_modifierKeyMapping.data(), s_modifierKeyMapping.size() });
if (match)
{
const auto v = match.value();
const auto& v = match.value();
if (!v.sequence.empty())
{
std::wstring modified{ v.sequence }; // Make a copy so we can modify it.
Expand Down
6 changes: 5 additions & 1 deletion src/terminal/parser/InputStateMachineEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ bool InputStateMachineEngine::ActionCsiDispatch(const wchar_t wch,
// even if we failed to parse a portion of this sequence.
success = _UpdateSGRMouseButtonState(wch, parameters, buttonState, eventFlags) && success;
success = success && _WriteMouseEvent(col, row, buttonState, modifierState, eventFlags);
break;
}
default:
success = false;
Expand All @@ -432,6 +433,7 @@ bool InputStateMachineEngine::ActionCsiDispatch(const wchar_t wch,
success = _GetXYPosition(parameters, row, col);
break;
}
[[fallthrough]];
case CsiActionCodes::ArrowUp:
case CsiActionCodes::ArrowDown:
case CsiActionCodes::ArrowRight:
Expand Down Expand Up @@ -477,7 +479,7 @@ bool InputStateMachineEngine::ActionCsiDispatch(const wchar_t wch,
_lookingForDSR = false;
break;
}
__fallthrough;
[[fallthrough]];
case CsiActionCodes::Generic:
case CsiActionCodes::ArrowUp:
case CsiActionCodes::ArrowDown:
Expand Down Expand Up @@ -1364,6 +1366,8 @@ bool InputStateMachineEngine::_GenerateWin32Key(const gsl::span<const size_t> pa
case 1:
key.SetVirtualKeyCode(::base::saturated_cast<WORD>(til::at(parameters, 0)));
break;
default:
break;
}

return true;
Expand Down
12 changes: 12 additions & 0 deletions src/terminal/parser/OutputStateMachineEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ bool OutputStateMachineEngine::_IntermediateScsDispatch(const wchar_t wch,
success = _dispatch->Designate96Charset(3, charset);
TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG3);
break;
default:
success = false;
break;
}

return success;
Expand Down Expand Up @@ -806,9 +809,15 @@ bool OutputStateMachineEngine::_IntermediateGreaterThanOrEqualDispatch(const wch
success = _dispatch->TertiaryDeviceAttributes();
TermTelemetry::Instance().Log(TermTelemetry::Codes::DA3);
break;
default:
success = false;
break;
}
}
break;
default:
success = false;
break;
}

return success;
Expand Down Expand Up @@ -1330,6 +1339,9 @@ bool OutputStateMachineEngine::_GetDeviceStatusOperation(const gsl::span<const s
statusType = DispatchTypes::AnsiStatusType::CPR_CursorPositionReport;
success = true;
break;
default:
success = false;
break;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/terminal/parser/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ bool Base64::s_Decode(const std::wstring_view src, std::wstring& dst) noexcept
dst.push_back(tmp);
state = 0;
break;
default:
break;
}

iter++;
Expand All @@ -154,6 +156,7 @@ bool Base64::s_Decode(const std::wstring_view src, std::wstring& dst) noexcept
return false;
}
iter++; // Skip the padding character and fallthrough to "single trailing padding character" case.
[[fallthrough]];
case 3:
while (iter < src.cend())
{
Expand All @@ -163,6 +166,9 @@ bool Base64::s_Decode(const std::wstring_view src, std::wstring& dst) noexcept
}
iter++;
}
break;
default:
break;
}
}
else if (state != 0) // When no padding, we must be in state 0.
Expand Down

0 comments on commit b7e4fb1

Please sign in to comment.