You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang-tidy] Fix crash on "reference-to-array" parameters in 'bugprone-easily-swappable-parameters'
An otherwise unexercised code path related to trying to model
"array-to-pointer decay" resulted in a null pointer dereference crash
when parameters of type "reference to array" were encountered.
Fixes crash report http://bugs.llvm.org/show_bug.cgi?id=50995.
Reviewed By: aaron.ballman
Differential Revision: http://reviews.llvm.org/D106946
voidtemplatedArrayRef(int (&Array1)[N], int (&Array2)[M]) {}
51
+
// NO-WARN: Distinct template types in the primary template.
52
+
53
+
voidtemplatedArrayRefTest() {
54
+
int Foo[12], Bar[12];
55
+
templatedArrayRef(Foo, Bar);
56
+
57
+
int Baz[12], Quux[42];
58
+
templatedArrayRef(Baz, Quux);
59
+
60
+
// NO-WARN: Implicit instantiations are not checked.
61
+
}
62
+
63
+
template <>
64
+
voidtemplatedArrayRef(int (&Array1)[8], int (&Array2)[8]) { templatedArrayRef(Array2, Array1); }
65
+
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 2 adjacent parameters of 'templatedArrayRef<8, 8>' of similar type ('int (&)[8]') are
66
+
// CHECK-MESSAGES: :[[@LINE-2]]:30: note: the first parameter in the range is 'Array1'
67
+
// CHECK-MESSAGES: :[[@LINE-3]]:48: note: the last parameter in the range is 'Array2'
68
+
69
+
template <>
70
+
voidtemplatedArrayRef(int (&Array1)[16], int (&Array2)[24]) {}
71
+
// NO-WARN: Not the same type.
72
+
29
73
voidnumericConversion1(int I, double D) { numericConversion1(D, I); }
30
74
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 2 adjacent parameters of 'numericConversion1' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters]
31
75
// CHECK-MESSAGES: :[[@LINE-2]]:29: note: the first parameter in the range is 'I'
0 commit comments