From 120fb9a164d5a26cab04ba84f6d6671317957d1f Mon Sep 17 00:00:00 2001 From: Michael Niksa Date: Mon, 17 Aug 2020 10:37:53 -0700 Subject: [PATCH 1/2] Compensate for new warnings and STL changes in VS 16.7 --- src/buffer/out/UnicodeStorage.cpp | 2 +- src/buffer/out/UnicodeStorage.hpp | 2 +- .../PublicTerminalCore/HwndTerminal.cpp | 4 ++++ src/cascadia/TerminalConnection/init.cpp | 2 ++ src/inc/til/bitmap.h | 2 +- src/renderer/dx/DxRenderer.cpp | 2 +- src/terminal/adapter/adaptDispatch.cpp | 6 +++++ src/terminal/adapter/terminalOutput.cpp | 9 +++++--- src/terminal/input/mouseInput.cpp | 22 ++++++++++++------- src/terminal/input/terminalInput.cpp | 2 +- .../parser/InputStateMachineEngine.cpp | 6 ++++- .../parser/OutputStateMachineEngine.cpp | 12 ++++++++++ src/terminal/parser/base64.cpp | 6 +++++ 13 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/buffer/out/UnicodeStorage.cpp b/src/buffer/out/UnicodeStorage.cpp index 1f4c1831ae2..7de3c11025a 100644 --- a/src/buffer/out/UnicodeStorage.cpp +++ b/src/buffer/out/UnicodeStorage.cpp @@ -35,7 +35,7 @@ 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 -void UnicodeStorage::Erase(const key_type key) +void UnicodeStorage::Erase(const key_type key) noexcept { _map.erase(key); } diff --git a/src/buffer/out/UnicodeStorage.hpp b/src/buffer/out/UnicodeStorage.hpp index d37a01a2aeb..e1bd2ff3659 100644 --- a/src/buffer/out/UnicodeStorage.hpp +++ b/src/buffer/out/UnicodeStorage.hpp @@ -53,7 +53,7 @@ class UnicodeStorage final void StoreGlyph(const key_type key, const mapped_type& glyph); - void Erase(const key_type key); + void Erase(const key_type key) noexcept; void Remap(const std::unordered_map& rowMap, const std::optional width); diff --git a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp index c194e5d77a8..01d78f77a32 100644 --- a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp +++ b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp @@ -79,6 +79,8 @@ try case WM_RBUTTONUP: ReleaseCapture(); break; + default: + break; } // Suppress all mouse events that made it into the terminal. @@ -132,6 +134,8 @@ try terminal->_hwnd.release(); terminal->Teardown(); return 0; + default: + break; } } return DefWindowProc(hwnd, uMsg, wParam, lParam); diff --git a/src/cascadia/TerminalConnection/init.cpp b/src/cascadia/TerminalConnection/init.cpp index 12ce0ec8770..0d1e411aa17 100644 --- a/src/cascadia/TerminalConnection/init.cpp +++ b/src/cascadia/TerminalConnection/init.cpp @@ -28,6 +28,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD reason, LPVOID /*reserved*/) TraceLoggingUnregister(g_hTerminalConnectionProvider); } break; + default: + break; } return TRUE; diff --git a/src/inc/til/bitmap.h b/src/inc/til/bitmap.h index 26492815176..028123cc455 100644 --- a/src/inc/til/bitmap.h +++ b/src/inc/til/bitmap.h @@ -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 diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index 8e851e62cc0..72b1a1e8fc8 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -1417,7 +1417,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 diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index 7578e4fbc9a..8d656e572dd 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -1578,6 +1578,9 @@ bool AdaptDispatch::TabClear(const size_t clearType) case DispatchTypes::TabClearType::ClearAllColumns: success = _ClearAllTabStops(); break; + default: + success = false; + break; } return success; } @@ -1695,6 +1698,9 @@ bool AdaptDispatch::DesignateCodingSystem(const wchar_t codingSystem) _termOutput.EnableGrTranslation(false); } break; + default: + success = false; + break; } return success; } diff --git a/src/terminal/adapter/terminalOutput.cpp b/src/terminal/adapter/terminalOutput.cpp index a7b7c58aee7..f320839ac5f 100644 --- a/src/terminal/adapter/terminalOutput.cpp +++ b/src/terminal/adapter/terminalOutput.cpp @@ -66,8 +66,9 @@ bool TerminalOutput::Designate94Charset(size_t gsetNumber, const std::pair 0 ? 0x40 : 0x41; + break; + default: + xvalue = 0; + break; } if (isHover) { @@ -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) { diff --git a/src/terminal/input/terminalInput.cpp b/src/terminal/input/terminalInput.cpp index 54a99a925cd..8f5c5c4f7f3 100644 --- a/src/terminal/input/terminalInput.cpp +++ b/src/terminal/input/terminalInput.cpp @@ -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. diff --git a/src/terminal/parser/InputStateMachineEngine.cpp b/src/terminal/parser/InputStateMachineEngine.cpp index 59f34e20ab9..a4d903f5644 100644 --- a/src/terminal/parser/InputStateMachineEngine.cpp +++ b/src/terminal/parser/InputStateMachineEngine.cpp @@ -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; @@ -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: @@ -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: @@ -1364,6 +1366,8 @@ bool InputStateMachineEngine::_GenerateWin32Key(const gsl::span pa case 1: key.SetVirtualKeyCode(::base::saturated_cast(til::at(parameters, 0))); break; + default: + break; } return true; diff --git a/src/terminal/parser/OutputStateMachineEngine.cpp b/src/terminal/parser/OutputStateMachineEngine.cpp index 4d5b4d0c8ac..91a90a8accc 100644 --- a/src/terminal/parser/OutputStateMachineEngine.cpp +++ b/src/terminal/parser/OutputStateMachineEngine.cpp @@ -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; @@ -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; @@ -1330,6 +1339,9 @@ bool OutputStateMachineEngine::_GetDeviceStatusOperation(const gsl::span Date: Tue, 18 Aug 2020 09:34:54 -0700 Subject: [PATCH 2/2] revert noexcept on map erase because 16.6.5 is still on the build machines. --- src/buffer/out/UnicodeStorage.cpp | 7 ++++++- src/buffer/out/UnicodeStorage.hpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/buffer/out/UnicodeStorage.cpp b/src/buffer/out/UnicodeStorage.cpp index 7de3c11025a..bfc236e06bf 100644 --- a/src/buffer/out/UnicodeStorage.cpp +++ b/src/buffer/out/UnicodeStorage.cpp @@ -35,7 +35,12 @@ 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 -void UnicodeStorage::Erase(const key_type key) noexcept +// ~~~~~~~~~~~~~~ +// 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); } diff --git a/src/buffer/out/UnicodeStorage.hpp b/src/buffer/out/UnicodeStorage.hpp index e1bd2ff3659..d37a01a2aeb 100644 --- a/src/buffer/out/UnicodeStorage.hpp +++ b/src/buffer/out/UnicodeStorage.hpp @@ -53,7 +53,7 @@ class UnicodeStorage final void StoreGlyph(const key_type key, const mapped_type& glyph); - void Erase(const key_type key) noexcept; + void Erase(const key_type key); void Remap(const std::unordered_map& rowMap, const std::optional width);