File tree 3 files changed +17
-1
lines changed 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -753,6 +753,7 @@ void LoopConvertCheck::doConversion(
753
753
bool IsCheapToCopy =
754
754
!Descriptor.ElemType .isNull () &&
755
755
Descriptor.ElemType .isTriviallyCopyableType (*Context) &&
756
+ !Descriptor.ElemType ->isDependentSizedArrayType () &&
756
757
// TypeInfo::Width is in bits.
757
758
Context->getTypeInfo (Descriptor.ElemType ).Width <= 8 * MaxCopySize;
758
759
bool UseCopy = CanCopy && ((VarNameFromAlias && !AliasVarIsRef) ||
Original file line number Diff line number Diff line change @@ -271,7 +271,8 @@ Changes in existing checks
271
271
272
272
- Improved :doc: `modernize-loop-convert
273
273
<clang-tidy/checks/modernize/loop-convert>` to support for-loops with
274
- iterators initialized by free functions like ``begin ``, ``end ``, or ``size ``.
274
+ iterators initialized by free functions like ``begin ``, ``end ``, or ``size ``
275
+ and avoid crash for array of dependent array.
275
276
276
277
- Improved :doc: `modernize-return-braced-init-list
277
278
<clang-tidy/checks/modernize/return-braced-init-list>` check to ignore
Original file line number Diff line number Diff line change @@ -939,4 +939,18 @@ void fundamentalTypesTest() {
939
939
// CHECK-FIXES: for (double Double : Doubles)
940
940
}
941
941
942
+ template <unsigned p> void _dependenceArrayTest () {
943
+ unsigned test[3 ][p];
944
+ for (unsigned i = 0 ; i < p; ++i)
945
+ for (unsigned j = 0 ; j < 3 ; ++j)
946
+ printf (" %d" , test[j][i]);
947
+ // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
948
+ // CHECK-FIXES: (auto & j : test)
949
+ // CHECK-FIXES: printf("%d", j[i]);
950
+ }
951
+ void dependenceArrayTest () {
952
+ _dependenceArrayTest<1 >();
953
+ _dependenceArrayTest<2 >();
954
+ }
955
+
942
956
} // namespace PseudoArray
You can’t perform that action at this time.
0 commit comments