Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-tidy][modernize-loop-convert]check isDependentSizedArrayType #69062

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ void LoopConvertCheck::doConversion(
bool IsCheapToCopy =
!Descriptor.ElemType.isNull() &&
Descriptor.ElemType.isTriviallyCopyableType(*Context) &&
!Descriptor.ElemType->isDependentSizedArrayType() &&
// TypeInfo::Width is in bits.
Context->getTypeInfo(Descriptor.ElemType).Width <= 8 * MaxCopySize;
bool UseCopy = CanCopy && ((VarNameFromAlias && !AliasVarIsRef) ||
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ Changes in existing checks
<clang-tidy/checks/modernize/loop-convert>` to support for-loops with
iterators initialized by free functions like ``begin``, ``end``, or ``size``.

- Improved :doc:`modernize-loop-convert
HerrCai0907 marked this conversation as resolved.
Show resolved Hide resolved
<clang-tidy/checks/modernize/loop-convert>` to avoid crash dor dependent
array.

- Improved :doc:`modernize-return-braced-init-list
<clang-tidy/checks/modernize/return-braced-init-list>` check to ignore
false-positives when constructing the container with ``count`` copies of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,4 +939,13 @@ void fundamentalTypesTest() {
// CHECK-FIXES: for (double Double : Doubles)
}

template <unsigned int p> void test() {
unsigned int test[3][p];
// Initialize to zero
for (unsigned int i = 0; i < p; ++i)
for (unsigned int j = 0; j < 3; ++j) // CHECK-MESSAGES: warning: use range-based for loop instead
HerrCai0907 marked this conversation as resolved.
Show resolved Hide resolved
// CHECK-FIXES: (auto & j : test)
test[j][i] = 0;
}

} // namespace PseudoArray