Skip to content

Commit 736347b

Browse files
committed
Do it properly, also add release notes
1 parent 4be37e6 commit 736347b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
378378
if (const auto *Type = dyn_cast<ArrayType>(SizeofArgTy)) {
379379
// check if the array element size is larger than one. If true,
380380
// the size of the array is higher than the number of elements
381-
if (!getSizeOfType(Ctx, Type).isOne()) {
381+
if (!getSizeOfType(Ctx, Type->getElementType().getTypePtr()).isOne()) {
382382
diag(SzOfExpr->getBeginLoc(),
383383
"suspicious usage of 'sizeof' in the loop")
384384
<< SzOfExpr->getSourceRange();

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ Changes in existing checks
231231
<clang-tidy/checks/bugprone/signed-char-misuse>` check by fixing
232232
false positives on C23 enums with the fixed underlying type of signed char.
233233

234+
- Improved :doc:`bugprone-sizeof-expression
235+
<clang-tidy/checks/bugprone/sizeof-expression>` check by fixing
236+
a crash on ``sizeof`` of an array of template type.
237+
234238
- Improved :doc:`bugprone-tagged-union-member-count
235239
<clang-tidy/checks/bugprone/tagged-union-member-count>` by fixing a false
236240
positive when enums or unions from system header files or the ``std``

0 commit comments

Comments
 (0)