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
Do not warn when two parameter constructor receives pointer address from
a std::addressof method and the span size is set to 1.
(rdar://139298119)
Co-authored-by: MalavikaSamak <malavika2@apple.com>
return std::span<int>{p, 10}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
75
81
}
76
82
83
+
// addressof method defined outside std namespace.
84
+
template <class_Tp>
85
+
_Tp* addressof(_Tp& __x) {
86
+
return &__x;
87
+
}
88
+
77
89
voidnotWarnSafeCases(unsigned n, int *p) {
78
90
int X;
79
91
unsigned Y = 10;
80
92
std::span<int> S = std::span{&X, 1}; // no-warning
93
+
S = std::span{std::addressof(X), 1}; // no-warning
81
94
int Arr[10];
82
95
typedefint TenInts_t[10];
83
96
TenInts_t Arr2;
84
97
85
98
S = std::span{&X, 2}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
99
+
S = std::span{std::addressof(X), 2}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
100
+
// Warn when a non std method also named addressof
101
+
S = std::span{addressof(X), 1}; // expected-warning{{the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information}}
0 commit comments