Skip to content

Commit

Permalink
Fix building with v143 toolchain (#10727)
Browse files Browse the repository at this point in the history
Visual Studio 2022 Preview recently released the v143 toolchain.
C4189 is now flagging several unused variables, which breaks our build.

## PR Checklist

* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed

* CascadiaPackage builds ✔️
* All tests build ✔️
  • Loading branch information
lhecker authored Jul 20, 2021
1 parent 9c1331a commit 79115e2
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 50 deletions.
6 changes: 3 additions & 3 deletions src/buffer/out/textBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ bool TextBuffer::InsertCharacter(const std::wstring_view chars,

// Store character and double byte data
CharRow& charRow = Row.GetCharRow();
short const cBufferWidth = GetSize().Width();

try
{
Expand Down Expand Up @@ -1650,13 +1649,14 @@ const TextBuffer::TextAndColor TextBuffer::GetText(const bool includeCRLF,

if (!cell.DbcsAttr().IsTrailing())
{
selectionText.append(cell.Chars());
const auto chars = cell.Chars();
selectionText.append(chars);

if (copyTextColor)
{
const auto cellData = cell.TextAttr();
const auto [CellFgAttr, CellBkAttr] = GetAttributeColors(cellData);
for (const wchar_t wch : cell.Chars())
for (size_t j = 0; j < chars.size(); ++j)
{
selectionFgAttr.push_back(CellFgAttr);
selectionBkAttr.push_back(CellBkAttr);
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@ winrt::fire_and_forget Pane::_CloseChildRoutine(const bool closeFirst)
auto removedChild = closeFirst ? _firstChild : _secondChild;
auto remainingChild = closeFirst ? _secondChild : _firstChild;
const bool splitWidth = _splitState == SplitState::Vertical;
const auto totalSize = splitWidth ? _root.ActualWidth() : _root.ActualHeight();

Size removedOriginalSize{
::base::saturated_cast<float>(removedChild->_root.ActualWidth()),
Expand Down
6 changes: 0 additions & 6 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,10 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
}

const auto dx = ::base::ClampSub(viewportSize.X, oldDimensions.X);

const auto oldTop = _mutableViewport.Top();

const short newBufferHeight = ::base::ClampAdd(viewportSize.Y, _scrollbackLines);

COORD bufferSize{ viewportSize.X, newBufferHeight };

// Save cursor's relative height versus the viewport
const short sCursorHeightInViewportBefore = ::base::ClampSub(_buffer->GetCursor().GetPosition().Y, _mutableViewport.Top());

// This will be used to determine where the viewport should be in the new buffer.
const short oldViewportTop = _mutableViewport.Top();
short newViewportTop = oldViewportTop;
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/UnitTests_Remoting/RemotingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ namespace RemotingUnitTests

auto m0 = make_private<Remoting::implementation::Monarch>(monarch0PID);
auto p1 = make_private<Remoting::implementation::Peasant>(peasant1PID);
auto p2 = make_private<Remoting::implementation::Peasant>(peasant1PID);
auto p2 = make_private<Remoting::implementation::Peasant>(peasant2PID);

p1->WindowName(L"one");
p2->WindowName(L"two");
Expand Down
14 changes: 0 additions & 14 deletions src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,6 @@ void ConptyRoundtripTests::PassthroughClearAll()
}

auto verifyBuffer = [&](const TextBuffer& tb, const til::rectangle viewport, const bool afterClear = false) {
const auto firstRow = viewport.top<short>();
const auto width = viewport.width<short>();

// "~" rows
Expand Down Expand Up @@ -1781,7 +1780,6 @@ void ConptyRoundtripTests::ClearHostTrickeryTest()
END_TEST_METHOD_PROPERTIES();
constexpr int PaintEveryNewline = 0;
constexpr int PaintAfterAllNewlines = 1;
constexpr int DontPaintAfterNewlines = 2;

INIT_TEST_PROPERTY(int, paintEachNewline, L"Any of: manually PaintFrame after each newline is emitted, once at the end of all newlines, or not at all");
INIT_TEST_PROPERTY(bool, cursorOnNextLine, L"Either leave the cursor on the first line, or place it on the second line of the buffer");
Expand Down Expand Up @@ -2562,7 +2560,6 @@ void ConptyRoundtripTests::ResizeRepaintVimExeBuffer()
sm.ProcessString(L"BBB");
sm.ProcessString(L"\r\n");

const auto end = 2 * hostView.Height();
for (auto i = 2; i < hostView.BottomInclusive(); i++)
{
// IMPORTANT! The way vim writes these blank lines is as '~' followed by
Expand All @@ -2581,10 +2578,6 @@ void ConptyRoundtripTests::ResizeRepaintVimExeBuffer()

drawVim();

const auto firstTextLength = TerminalViewWidth - 2;
const auto spacesLength = 3;
const auto secondTextLength = 1;

auto verifyBuffer = [&](const TextBuffer& tb, const til::rectangle viewport) {
const auto firstRow = viewport.top<short>();
const auto width = viewport.width<short>();
Expand Down Expand Up @@ -2696,7 +2689,6 @@ void ConptyRoundtripTests::ClsAndClearHostClearsScrollbackTest()
}

auto verifyBuffer = [&](const TextBuffer& tb, const til::rectangle viewport, const bool afterClear = false) {
const auto firstRow = viewport.top<short>();
const auto width = viewport.width<short>();

// "~" rows
Expand Down Expand Up @@ -2910,8 +2902,6 @@ void ConptyRoundtripTests::ResizeInitializeBufferWithDefaultAttrs()
// { static_cast<BYTE>(XTERM_GREEN_ATTR) });
terminalGreenAttrs.SetIndexedBackground(XTERM_GREEN_ATTR);

const size_t width = static_cast<size_t>(TerminalViewWidth);

// Use an initial ^[[m to start printing with default-on-default
sm.ProcessString(L"\x1b[m");

Expand Down Expand Up @@ -3043,8 +3033,6 @@ void ConptyRoundtripTests::NewLinesAtBottomWithBackground()
terminalBlueAttrs.SetIndexedForeground(XTERM_GREEN_ATTR);
terminalBlueAttrs.SetIndexedBackground(XTERM_BLUE_ATTR);

const size_t width = static_cast<size_t>(TerminalViewWidth);

// We're going to print 4 more rows than the entire height of the viewport,
// causing the buffer to circle 4 times. This is 2 extra iterations of the
// two lines we're printing per iteration.
Expand Down Expand Up @@ -3162,7 +3150,6 @@ void ConptyRoundtripTests::WrapNewLineAtBottom()
// timings for the frame affect the results. In this test we'll be printing
// a bunch of paired lines. These values control when the PaintFrame calls
// will occur:
constexpr int DontPaint = 0; // Only paint at the end of all the output
constexpr int PaintAfterBothLines = 1; // Paint after each pair of lines is output
constexpr int PaintEveryLine = 2; // Paint after each and every line is output.

Expand Down Expand Up @@ -3343,7 +3330,6 @@ void ConptyRoundtripTests::WrapNewLineAtBottomLikeMSYS()
// timings for the frame affect the results. In this test we'll be printing
// a bunch of paired lines. These values control when the PaintFrame calls
// will occur:
constexpr int DontPaint = 0; // Only paint at the end of all the output
constexpr int PaintAfterBothLines = 1; // Paint after each pair of lines is output
constexpr int PaintEveryLine = 2; // Paint after each and every line is output.

Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ LRESULT IslandWindow::_OnMoving(const WPARAM /*wParam*/, const LPARAM lParam)

void IslandWindow::Initialize()
{
const bool initialized = (_interopWindowHandle != nullptr);

_source = DesktopWindowXamlSource{};

auto interop = _source.as<IDesktopWindowXamlSourceNative>();
Expand Down
2 changes: 0 additions & 2 deletions src/host/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,6 @@ size_t RetrieveNumberOfSpaces(_In_ SHORT sOriginalCursorPositionX,
return STATUS_BUFFER_TOO_SMALL;
}

const size_t OutputBufferSize = buffer.size_bytes();

if (readHandleState.IsInputPending())
{
return _ReadPendingInput(inputBuffer,
Expand Down
1 change: 0 additions & 1 deletion src/interactivity/base/EventSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ std::deque<std::unique_ptr<KeyEvent>> Microsoft::Console::Interactivity::Synthes
UNICODE_NULL,
LEFT_ALT_PRESSED));

const int radix = 10;
std::wstring wstr{ wch };
const auto convertedChars = ConvertToA(codepage, wstr);
if (convertedChars.size() == 1)
Expand Down
1 change: 0 additions & 1 deletion src/interactivity/win32/windowproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ using namespace Microsoft::Console::Types;

// First retrieve the new DPI and the current DPI.
DWORD const dpiProposed = (WORD)wParam;
DWORD const dpiCurrent = g.dpi;

// Now we need to get what the font size *would be* if we had this new DPI. We need to ask the renderer about that.
const FontInfo& fiCurrent = ScreenInfo.GetCurrentFont();
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/vt/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ VtEngine::VtEngine(_In_ wil::unique_hfile pipe,
// - S_OK or suitable HRESULT error from writing pipe.
[[nodiscard]] HRESULT VtEngine::_WriteTerminalAscii(const std::wstring_view wstr) noexcept
{
const size_t cchActual = wstr.length();

std::string needed;
needed.reserve(wstr.size());

Expand Down
20 changes: 4 additions & 16 deletions src/til/ut_til/MathTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ class MathTests

_RunCases(til::math::truncating, cases);

const auto fn = []() {
const auto v = til::math::details::truncating_t::cast<ptrdiff_t>(NAN);
};
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
VERIFY_THROWS_SPECIFIC(til::math::details::truncating_t::cast<ptrdiff_t>(NAN), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
}

TEST_METHOD(Ceiling)
Expand All @@ -65,10 +62,7 @@ class MathTests

_RunCases(til::math::ceiling, cases);

const auto fn = []() {
const auto v = til::math::details::ceiling_t::cast<ptrdiff_t>(NAN);
};
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
VERIFY_THROWS_SPECIFIC(til::math::details::ceiling_t::cast<ptrdiff_t>(NAN), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
}

TEST_METHOD(Flooring)
Expand All @@ -86,10 +80,7 @@ class MathTests

_RunCases(til::math::flooring, cases);

const auto fn = []() {
const auto v = til::math::details::flooring_t::cast<ptrdiff_t>(NAN);
};
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
VERIFY_THROWS_SPECIFIC(til::math::details::flooring_t::cast<ptrdiff_t>(NAN), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
}

TEST_METHOD(Rounding)
Expand All @@ -107,10 +98,7 @@ class MathTests

_RunCases(til::math::rounding, cases);

const auto fn = []() {
const auto v = til::math::details::rounding_t::cast<ptrdiff_t>(NAN);
};
VERIFY_THROWS_SPECIFIC(fn(), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
VERIFY_THROWS_SPECIFIC(til::math::details::rounding_t::cast<ptrdiff_t>(NAN), wil::ResultException, [](wil::ResultException& e) { return e.GetErrorCode() == E_ABORT; });
}

TEST_METHOD(NormalIntegers)
Expand Down
1 change: 0 additions & 1 deletion src/til/ut_til/PointTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ class PointTests

Log::Comment(L"4.) Division by zero");
{
constexpr ptrdiff_t bigSize = std::numeric_limits<ptrdiff_t>().max();
const til::point pt{ 1, 1 };
const int scale = 0;

Expand Down

0 comments on commit 79115e2

Please sign in to comment.