Fix SA for Visual Studio 16.8 (#8551)
I added `enum class` to one thing and decided that that was quite enough before disabling the `enum class` warning. Looks like 16.8 made more map/vector operations noexcept, so we have to re-annotate to remain compliant.
This commit is contained in:
parent
4111be389d
commit
eb2be374fd
|
@ -11,6 +11,9 @@
|
||||||
<Rule Id="C26466" Action="None" />
|
<Rule Id="C26466" Action="None" />
|
||||||
<!-- This one has caught us off guard as it suddenly showed up. Re-enablement is going to be in #2941 -->
|
<!-- This one has caught us off guard as it suddenly showed up. Re-enablement is going to be in #2941 -->
|
||||||
<Rule Id="C26814" Action="None" />
|
<Rule Id="C26814" Action="None" />
|
||||||
|
|
||||||
|
<!-- There are *so many* enums that should be enum classes. -->
|
||||||
|
<Rule Id="C26812" Action="None" />
|
||||||
</Rules>
|
</Rules>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,12 @@ AttrRowIterator::AttrRowIterator(const ATTR_ROW* const attrRow) noexcept :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrRowIterator::operator bool() const
|
AttrRowIterator::operator bool() const noexcept
|
||||||
{
|
{
|
||||||
return !_exceeded && _run < _pAttrRow->_list.cend();
|
return !_exceeded && _run < _pAttrRow->_list.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttrRowIterator::operator==(const AttrRowIterator& it) const
|
bool AttrRowIterator::operator==(const AttrRowIterator& it) const noexcept
|
||||||
{
|
{
|
||||||
return (_pAttrRow == it._pAttrRow &&
|
return (_pAttrRow == it._pAttrRow &&
|
||||||
_run == it._run &&
|
_run == it._run &&
|
||||||
|
@ -34,18 +34,18 @@ bool AttrRowIterator::operator==(const AttrRowIterator& it) const
|
||||||
_exceeded == it._exceeded);
|
_exceeded == it._exceeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttrRowIterator::operator!=(const AttrRowIterator& it) const
|
bool AttrRowIterator::operator!=(const AttrRowIterator& it) const noexcept
|
||||||
{
|
{
|
||||||
return !(*this == it);
|
return !(*this == it);
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrRowIterator& AttrRowIterator::operator++()
|
AttrRowIterator& AttrRowIterator::operator++() noexcept
|
||||||
{
|
{
|
||||||
_increment(1);
|
_increment(1);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrRowIterator AttrRowIterator::operator++(int)
|
AttrRowIterator AttrRowIterator::operator++(int) noexcept
|
||||||
{
|
{
|
||||||
auto copy = *this;
|
auto copy = *this;
|
||||||
_increment(1);
|
_increment(1);
|
||||||
|
@ -74,13 +74,13 @@ AttrRowIterator& AttrRowIterator::operator-=(const ptrdiff_t& movement)
|
||||||
return this->operator+=(-movement);
|
return this->operator+=(-movement);
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrRowIterator& AttrRowIterator::operator--()
|
AttrRowIterator& AttrRowIterator::operator--() noexcept
|
||||||
{
|
{
|
||||||
_decrement(1);
|
_decrement(1);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrRowIterator AttrRowIterator::operator--(int)
|
AttrRowIterator AttrRowIterator::operator--(int) noexcept
|
||||||
{
|
{
|
||||||
auto copy = *this;
|
auto copy = *this;
|
||||||
_decrement(1);
|
_decrement(1);
|
||||||
|
@ -103,7 +103,7 @@ const TextAttribute& AttrRowIterator::operator*() const
|
||||||
// - increments the index the iterator points to
|
// - increments the index the iterator points to
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// - count - the amount to increment by
|
// - count - the amount to increment by
|
||||||
void AttrRowIterator::_increment(size_t count)
|
void AttrRowIterator::_increment(size_t count) noexcept
|
||||||
{
|
{
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
|
@ -126,7 +126,7 @@ void AttrRowIterator::_increment(size_t count)
|
||||||
// - decrements the index the iterator points to
|
// - decrements the index the iterator points to
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// - count - the amount to decrement by
|
// - count - the amount to decrement by
|
||||||
void AttrRowIterator::_decrement(size_t count)
|
void AttrRowIterator::_decrement(size_t count) noexcept
|
||||||
{
|
{
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,19 +33,19 @@ public:
|
||||||
|
|
||||||
AttrRowIterator(const ATTR_ROW* const attrRow) noexcept;
|
AttrRowIterator(const ATTR_ROW* const attrRow) noexcept;
|
||||||
|
|
||||||
operator bool() const;
|
operator bool() const noexcept;
|
||||||
|
|
||||||
bool operator==(const AttrRowIterator& it) const;
|
bool operator==(const AttrRowIterator& it) const noexcept;
|
||||||
bool operator!=(const AttrRowIterator& it) const;
|
bool operator!=(const AttrRowIterator& it) const noexcept;
|
||||||
|
|
||||||
AttrRowIterator& operator++();
|
AttrRowIterator& operator++() noexcept;
|
||||||
AttrRowIterator operator++(int);
|
AttrRowIterator operator++(int) noexcept;
|
||||||
|
|
||||||
AttrRowIterator& operator+=(const ptrdiff_t& movement);
|
AttrRowIterator& operator+=(const ptrdiff_t& movement);
|
||||||
AttrRowIterator& operator-=(const ptrdiff_t& movement);
|
AttrRowIterator& operator-=(const ptrdiff_t& movement);
|
||||||
|
|
||||||
AttrRowIterator& operator--();
|
AttrRowIterator& operator--() noexcept;
|
||||||
AttrRowIterator operator--(int);
|
AttrRowIterator operator--(int) noexcept;
|
||||||
|
|
||||||
const TextAttribute* operator->() const;
|
const TextAttribute* operator->() const;
|
||||||
const TextAttribute& operator*() const;
|
const TextAttribute& operator*() const;
|
||||||
|
@ -56,7 +56,7 @@ private:
|
||||||
size_t _currentAttributeIndex; // index of TextAttribute within the current TextAttributeRun
|
size_t _currentAttributeIndex; // index of TextAttribute within the current TextAttributeRun
|
||||||
bool _exceeded;
|
bool _exceeded;
|
||||||
|
|
||||||
void _increment(size_t count);
|
void _increment(size_t count) noexcept;
|
||||||
void _decrement(size_t count);
|
void _decrement(size_t count) noexcept;
|
||||||
void _setToEnd() noexcept;
|
void _setToEnd() noexcept;
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,7 +139,7 @@ typename CharRow::const_iterator CharRow::cend() const noexcept
|
||||||
// - <none>
|
// - <none>
|
||||||
// Return Value:
|
// Return Value:
|
||||||
// - The calculated left boundary of the internal string.
|
// - The calculated left boundary of the internal string.
|
||||||
size_t CharRow::MeasureLeft() const
|
size_t CharRow::MeasureLeft() const noexcept
|
||||||
{
|
{
|
||||||
std::vector<value_type>::const_iterator it = _data.cbegin();
|
std::vector<value_type>::const_iterator it = _data.cbegin();
|
||||||
while (it != _data.cend() && it->IsSpace())
|
while (it != _data.cend() && it->IsSpace())
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
size_t size() const noexcept;
|
size_t size() const noexcept;
|
||||||
void Reset() noexcept;
|
void Reset() noexcept;
|
||||||
[[nodiscard]] HRESULT Resize(const size_t newSize) noexcept;
|
[[nodiscard]] HRESULT Resize(const size_t newSize) noexcept;
|
||||||
size_t MeasureLeft() const;
|
size_t MeasureLeft() const noexcept;
|
||||||
size_t MeasureRight() const noexcept;
|
size_t MeasureRight() const noexcept;
|
||||||
void ClearCell(const size_t column);
|
void ClearCell(const size_t column);
|
||||||
bool ContainsText() const noexcept;
|
bool ContainsText() const noexcept;
|
||||||
|
|
|
@ -2322,7 +2322,7 @@ uint16_t TextBuffer::GetHyperlinkId(std::wstring_view uri, std::wstring_view id)
|
||||||
// user defined id from the custom id map (if there is one)
|
// user defined id from the custom id map (if there is one)
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// - The ID of the hyperlink to be removed
|
// - The ID of the hyperlink to be removed
|
||||||
void TextBuffer::RemoveHyperlinkFromMap(uint16_t id)
|
void TextBuffer::RemoveHyperlinkFromMap(uint16_t id) noexcept
|
||||||
{
|
{
|
||||||
_hyperlinkMap.erase(id);
|
_hyperlinkMap.erase(id);
|
||||||
for (const auto& customIdPair : _hyperlinkCustomIdMap)
|
for (const auto& customIdPair : _hyperlinkCustomIdMap)
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
void AddHyperlinkToMap(std::wstring_view uri, uint16_t id);
|
void AddHyperlinkToMap(std::wstring_view uri, uint16_t id);
|
||||||
std::wstring GetHyperlinkUriFromId(uint16_t id) const;
|
std::wstring GetHyperlinkUriFromId(uint16_t id) const;
|
||||||
uint16_t GetHyperlinkId(std::wstring_view uri, std::wstring_view id);
|
uint16_t GetHyperlinkId(std::wstring_view uri, std::wstring_view id);
|
||||||
void RemoveHyperlinkFromMap(uint16_t id);
|
void RemoveHyperlinkFromMap(uint16_t id) noexcept;
|
||||||
std::wstring GetCustomIdFromId(uint16_t id) const;
|
std::wstring GetCustomIdFromId(uint16_t id) const;
|
||||||
void CopyHyperlinkMaps(const TextBuffer& OtherBuffer);
|
void CopyHyperlinkMaps(const TextBuffer& OtherBuffer);
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ TextBufferCellIterator::operator bool() const noexcept
|
||||||
// - it - The other iterator to compare to this one.
|
// - it - The other iterator to compare to this one.
|
||||||
// Return Value:
|
// Return Value:
|
||||||
// - True if it's the same text buffer and same cell position. False otherwise.
|
// - True if it's the same text buffer and same cell position. False otherwise.
|
||||||
bool TextBufferCellIterator::operator==(const TextBufferCellIterator& it) const
|
bool TextBufferCellIterator::operator==(const TextBufferCellIterator& it) const noexcept
|
||||||
{
|
{
|
||||||
return _pos == it._pos &&
|
return _pos == it._pos &&
|
||||||
&_buffer == &it._buffer &&
|
&_buffer == &it._buffer &&
|
||||||
|
@ -81,7 +81,7 @@ bool TextBufferCellIterator::operator==(const TextBufferCellIterator& it) const
|
||||||
// - it - The other iterator to compare to this one.
|
// - it - The other iterator to compare to this one.
|
||||||
// Return Value:
|
// Return Value:
|
||||||
// - True if it's the same text buffer and different cell position or if they're different buffers. False otherwise.
|
// - True if it's the same text buffer and different cell position or if they're different buffers. False otherwise.
|
||||||
bool TextBufferCellIterator::operator!=(const TextBufferCellIterator& it) const
|
bool TextBufferCellIterator::operator!=(const TextBufferCellIterator& it) const noexcept
|
||||||
{
|
{
|
||||||
return !(*this == it);
|
return !(*this == it);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ public:
|
||||||
|
|
||||||
operator bool() const noexcept;
|
operator bool() const noexcept;
|
||||||
|
|
||||||
bool operator==(const TextBufferCellIterator& it) const;
|
bool operator==(const TextBufferCellIterator& it) const noexcept;
|
||||||
bool operator!=(const TextBufferCellIterator& it) const;
|
bool operator!=(const TextBufferCellIterator& it) const noexcept;
|
||||||
|
|
||||||
TextBufferCellIterator& operator+=(const ptrdiff_t& movement);
|
TextBufferCellIterator& operator+=(const ptrdiff_t& movement);
|
||||||
TextBufferCellIterator& operator-=(const ptrdiff_t& movement);
|
TextBufferCellIterator& operator-=(const ptrdiff_t& movement);
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||||
std::wstring cmdline{ wil::ExpandEnvironmentStringsW<std::wstring>(_commandline.c_str()) }; // mutable copy -- required for CreateProcessW
|
std::wstring cmdline{ wil::ExpandEnvironmentStringsW<std::wstring>(_commandline.c_str()) }; // mutable copy -- required for CreateProcessW
|
||||||
|
|
||||||
Utils::EnvironmentVariableMapW environment;
|
Utils::EnvironmentVariableMapW environment;
|
||||||
auto zeroEnvMap = wil::scope_exit([&] {
|
auto zeroEnvMap = wil::scope_exit([&]() noexcept {
|
||||||
// Can't zero the keys, but at least we can zero the values.
|
// Can't zero the keys, but at least we can zero the values.
|
||||||
for (auto& [name, value] : environment)
|
for (auto& [name, value] : environment)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1516,13 +1516,13 @@ try
|
||||||
// offset by half the stroke width. For the start coordinate we add half
|
// offset by half the stroke width. For the start coordinate we add half
|
||||||
// the stroke width, and for the end coordinate we subtract half the width.
|
// the stroke width, and for the end coordinate we subtract half the width.
|
||||||
|
|
||||||
if (lines & (GridLines::Left | GridLines::Right))
|
if (WI_IsAnyFlagSet(lines, (GridLines::Left | GridLines::Right)))
|
||||||
{
|
{
|
||||||
const auto halfGridlineWidth = _lineMetrics.gridlineWidth / 2.0f;
|
const auto halfGridlineWidth = _lineMetrics.gridlineWidth / 2.0f;
|
||||||
const auto startY = target.y + halfGridlineWidth;
|
const auto startY = target.y + halfGridlineWidth;
|
||||||
const auto endY = target.y + font.height - halfGridlineWidth;
|
const auto endY = target.y + font.height - halfGridlineWidth;
|
||||||
|
|
||||||
if (lines & GridLines::Left)
|
if (WI_IsFlagSet(lines, GridLines::Left))
|
||||||
{
|
{
|
||||||
auto x = target.x + halfGridlineWidth;
|
auto x = target.x + halfGridlineWidth;
|
||||||
for (size_t i = 0; i < cchLine; i++, x += font.width)
|
for (size_t i = 0; i < cchLine; i++, x += font.width)
|
||||||
|
@ -1531,7 +1531,7 @@ try
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines & GridLines::Right)
|
if (WI_IsFlagSet(lines, GridLines::Right))
|
||||||
{
|
{
|
||||||
auto x = target.x + font.width - halfGridlineWidth;
|
auto x = target.x + font.width - halfGridlineWidth;
|
||||||
for (size_t i = 0; i < cchLine; i++, x += font.width)
|
for (size_t i = 0; i < cchLine; i++, x += font.width)
|
||||||
|
@ -1541,19 +1541,19 @@ try
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines & (GridLines::Top | GridLines::Bottom))
|
if (WI_IsAnyFlagSet(lines, GridLines::Top | GridLines::Bottom))
|
||||||
{
|
{
|
||||||
const auto halfGridlineWidth = _lineMetrics.gridlineWidth / 2.0f;
|
const auto halfGridlineWidth = _lineMetrics.gridlineWidth / 2.0f;
|
||||||
const auto startX = target.x + halfGridlineWidth;
|
const auto startX = target.x + halfGridlineWidth;
|
||||||
const auto endX = target.x + fullRunWidth - halfGridlineWidth;
|
const auto endX = target.x + fullRunWidth - halfGridlineWidth;
|
||||||
|
|
||||||
if (lines & GridLines::Top)
|
if (WI_IsFlagSet(lines, GridLines::Top))
|
||||||
{
|
{
|
||||||
const auto y = target.y + halfGridlineWidth;
|
const auto y = target.y + halfGridlineWidth;
|
||||||
DrawLine(startX, y, endX, y, _lineMetrics.gridlineWidth);
|
DrawLine(startX, y, endX, y, _lineMetrics.gridlineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines & GridLines::Bottom)
|
if (WI_IsFlagSet(lines, GridLines::Bottom))
|
||||||
{
|
{
|
||||||
const auto y = target.y + font.height - halfGridlineWidth;
|
const auto y = target.y + font.height - halfGridlineWidth;
|
||||||
DrawLine(startX, y, endX, y, _lineMetrics.gridlineWidth);
|
DrawLine(startX, y, endX, y, _lineMetrics.gridlineWidth);
|
||||||
|
@ -1563,24 +1563,24 @@ try
|
||||||
// In the case of the underline and strikethrough offsets, the stroke width
|
// In the case of the underline and strikethrough offsets, the stroke width
|
||||||
// is already accounted for, so they don't require further adjustments.
|
// is already accounted for, so they don't require further adjustments.
|
||||||
|
|
||||||
if (lines & (GridLines::Underline | GridLines::DoubleUnderline | GridLines::HyperlinkUnderline))
|
if (WI_IsAnyFlagSet(lines, GridLines::Underline | GridLines::DoubleUnderline | GridLines::HyperlinkUnderline))
|
||||||
{
|
{
|
||||||
const auto halfUnderlineWidth = _lineMetrics.underlineWidth / 2.0f;
|
const auto halfUnderlineWidth = _lineMetrics.underlineWidth / 2.0f;
|
||||||
const auto startX = target.x + halfUnderlineWidth;
|
const auto startX = target.x + halfUnderlineWidth;
|
||||||
const auto endX = target.x + fullRunWidth - halfUnderlineWidth;
|
const auto endX = target.x + fullRunWidth - halfUnderlineWidth;
|
||||||
const auto y = target.y + _lineMetrics.underlineOffset;
|
const auto y = target.y + _lineMetrics.underlineOffset;
|
||||||
|
|
||||||
if (lines & GridLines::Underline)
|
if (WI_IsFlagSet(lines, GridLines::Underline))
|
||||||
{
|
{
|
||||||
DrawLine(startX, y, endX, y, _lineMetrics.underlineWidth);
|
DrawLine(startX, y, endX, y, _lineMetrics.underlineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines & GridLines::HyperlinkUnderline)
|
if (WI_IsFlagSet(lines, GridLines::HyperlinkUnderline))
|
||||||
{
|
{
|
||||||
DrawHyperlinkLine(startX, y, endX, y, _lineMetrics.underlineWidth);
|
DrawHyperlinkLine(startX, y, endX, y, _lineMetrics.underlineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines & GridLines::DoubleUnderline)
|
if (WI_IsFlagSet(lines, GridLines::DoubleUnderline))
|
||||||
{
|
{
|
||||||
DrawLine(startX, y, endX, y, _lineMetrics.underlineWidth);
|
DrawLine(startX, y, endX, y, _lineMetrics.underlineWidth);
|
||||||
const auto y2 = target.y + _lineMetrics.underlineOffset2;
|
const auto y2 = target.y + _lineMetrics.underlineOffset2;
|
||||||
|
@ -1588,7 +1588,7 @@ try
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines & GridLines::Strikethrough)
|
if (WI_IsFlagSet(lines, GridLines::Strikethrough))
|
||||||
{
|
{
|
||||||
const auto halfStrikethroughWidth = _lineMetrics.strikethroughWidth / 2.0f;
|
const auto halfStrikethroughWidth = _lineMetrics.strikethroughWidth / 2.0f;
|
||||||
const auto startX = target.x + halfStrikethroughWidth;
|
const auto startX = target.x + halfStrikethroughWidth;
|
||||||
|
|
|
@ -72,7 +72,7 @@ void KeyEvent::ActivateModifierKey(const ModifierKeyState modifierKey) noexcept
|
||||||
SetActiveModifierKeys(keys);
|
SetActiveModifierKeys(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyEvent::DoActiveModifierKeysMatch(const std::unordered_set<ModifierKeyState>& consoleModifiers) const
|
bool KeyEvent::DoActiveModifierKeysMatch(const std::unordered_set<ModifierKeyState>& consoleModifiers) const noexcept
|
||||||
{
|
{
|
||||||
DWORD consoleBits = 0;
|
DWORD consoleBits = 0;
|
||||||
for (const ModifierKeyState& mod : consoleModifiers)
|
for (const ModifierKeyState& mod : consoleModifiers)
|
||||||
|
|
|
@ -297,7 +297,7 @@ public:
|
||||||
void SetActiveModifierKeys(const DWORD activeModifierKeys) noexcept;
|
void SetActiveModifierKeys(const DWORD activeModifierKeys) noexcept;
|
||||||
void DeactivateModifierKey(const ModifierKeyState modifierKey) noexcept;
|
void DeactivateModifierKey(const ModifierKeyState modifierKey) noexcept;
|
||||||
void ActivateModifierKey(const ModifierKeyState modifierKey) noexcept;
|
void ActivateModifierKey(const ModifierKeyState modifierKey) noexcept;
|
||||||
bool DoActiveModifierKeysMatch(const std::unordered_set<ModifierKeyState>& consoleModifiers) const;
|
bool DoActiveModifierKeysMatch(const std::unordered_set<ModifierKeyState>& consoleModifiers) const noexcept;
|
||||||
bool IsCommandLineEditingKey() const noexcept;
|
bool IsCommandLineEditingKey() const noexcept;
|
||||||
bool IsPopupKey() const noexcept;
|
bool IsPopupKey() const noexcept;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue