Skip to content

Commit a6cd351

Browse files
author
MalavikaSamak
committed
Moved the release notes and added more description to the release notes.
1 parent 2e0e01e commit a6cd351

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
379379
auto Loc = Result.Nodes.getNodeAs<Expr>("sizeof-expr");
380380

381381
if (const auto type = dyn_cast<ArrayType>(SizeofArgTy)) {
382+
// check if the array element size is larger than one. If true,
383+
// the size of the array is higher than the number of elements
382384
CharUnits sSize = Ctx.getTypeSizeInChars(type->getElementType());
383385
if (!sSize.isOne()) {
384386
diag(Loc->getBeginLoc(), "suspicious usage of 'sizeof' in the loop")

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ Changes in existing checks
146146
<clang-tidy/checks/bugprone/optional-value-conversion>` check to detect
147147
conversion in argument of ``std::make_optional``.
148148

149+
- Improved :doc: `bugprone-sizeof-expression
150+
<clang-tidy/checks/bugprone/bugprone-sizeof-expression>` check by adding
151+
`WarnOnSizeOfInLoopTermination` option to detect misuses of ``sizeof``
152+
expression in loop conditions. The check detects the use of ``sizeof``
153+
opertaor to determine the number of elements in the array, where the
154+
array size is higher than the number of elements in the array.
155+
149156
- Improved :doc:`bugprone-string-constructor
150157
<clang-tidy/checks/bugprone/string-constructor>` check to find suspicious
151158
calls of ``std::string`` constructor with char pointer, start position and
@@ -219,11 +226,6 @@ Changes in existing checks
219226
tolerating fix-it breaking compilation when functions is used as pointers
220227
to avoid matching usage of functions within the current compilation unit.
221228

222-
- Improved :doc: `bugprone-sizeof-expression
223-
<clang-tidy/checks/bugprone/bugprone-sizeof-expression>` check by adding
224-
`WarnOnSizeOfInLoopTermination` option to detect misuses of ``sizeof``
225-
expression in loop conditions.
226-
227229
Removed checks
228230
^^^^^^^^^^^^^^
229231

0 commit comments

Comments
 (0)