Skip to content

Commit e8e5a60

Browse files
committed
Remove changes in warn-unsafe-buffer-usage-libc-functions.cpp because of irrelevance.
1 parent 1e578f1 commit e8e5a60

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

clang/test/SemaCXX/warn-unsafe-buffer-usage-libc-functions.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
// RUN: -verify %s -x objective-c++
55
// RUN: %clang_cc1 -std=c++20 -Wno-all -Wunsafe-buffer-usage-in-libc-call \
66
// RUN: -verify %s
7-
// RUN: %clang_cc1 -std=c++20 -Wno-all -Wunsafe-buffer-usage \
8-
// RUN: -verify -fexperimental-bounds-safety-attributes %s -DINTEROP_MODE
97

10-
#ifndef INTEROP_MODE
118
typedef struct {} FILE;
129
void memcpy();
1310
void __asan_memcpy();
@@ -158,47 +155,3 @@ void ff(char * p, char * q, std::span<char> s, std::span<char> s2) {
158155
wcscpy_s();
159156
#pragma clang diagnostic pop
160157
}
161-
162-
#else
163-
164-
#include <ptrcheck.h>
165-
typedef unsigned size_t;
166-
167-
// expected-note@+2{{consider using a safe container and passing '.data()' to the parameter 'dst' and '.size()' to its dependent parameter 'size' or 'std::span' and passing '.first(...).data()' to the parameter 'dst'}}
168-
// expected-note@+1{{consider using a safe container and passing '.data()' to the parameter 'src' and '.size()' to its dependent parameter 'size' or 'std::span' and passing '.first(...).data()' to the parameter 'src'}}
169-
void memcpy(void * __sized_by(size) dst, const void * __sized_by(size) src, unsigned size);
170-
unsigned strlen( const char* __null_terminated str );
171-
// expected-note@+1{{consider using a safe container and passing '.data()' to the parameter 'buffer' and '.size()' to its dependent parameter 'buf_size' or 'std::span' and passing '.first(...).data()' to the parameter 'buffer'}}
172-
int snprintf( char* __counted_by(buf_size) buffer, unsigned buf_size, const char* format, ... );
173-
int snwprintf( char* __counted_by(buf_size) buffer, unsigned buf_size, const char* format, ... );
174-
int vsnprintf( char* __counted_by(buf_size) buffer, unsigned buf_size, const char* format, ... );
175-
int sprintf( char* __counted_by(10) buffer, const char* format, ... );
176-
177-
void test(char * p, char * q, const char * str,
178-
const char * __null_terminated safe_str,
179-
char * __counted_by(n) safe_p,
180-
size_t n,
181-
char * __counted_by(10) safe_ten) {
182-
memcpy(p, q, 10); // expected-warning2{{unsafe assignment to function parameter of count-attributed type}}
183-
snprintf(p, 10, "%s", "hlo"); // expected-warning{{unsafe assignment to function parameter of count-attributed type}}
184-
185-
// We still warn about unsafe string pointer arguments to printfs:
186-
187-
snprintf(safe_p, n, "%s", str); // expected-warning{{function 'snprintf' is unsafe}} expected-note{{string argument is not guaranteed to be null-terminated}}
188-
snwprintf(safe_p, n, "%s", str); // expected-warning{{function 'snwprintf' is unsafe}} expected-note{{string argument is not guaranteed to be null-terminated}}
189-
190-
memcpy(safe_p, safe_p, n); // no warn
191-
strlen(str); // expected-warning{{unsafe assignment to a parameter of '__null_terminated' type; only '__null_terminated' pointers, string literals, and 'std::string::c_str' calls are compatible with '__null_terminated' pointers}}
192-
snprintf(safe_p, n, "%s", "hlo"); // no warn
193-
snprintf(safe_p, n, "%s", safe_str); // no warn
194-
snwprintf(safe_p, n, "%s", safe_str); // no warn
195-
196-
// v-printf functions and sprintf are still warned about because
197-
// they cannot be fully safe:
198-
199-
vsnprintf(safe_p, n, "%s", safe_str); // expected-warning{{function 'vsnprintf' is unsafe}} expected-note{{'va_list' is unsafe}}
200-
sprintf(safe_ten, "%s", safe_str); // expected-warning{{function 'sprintf' is unsafe}} expected-note{{change to 'snprintf' for explicit bounds checking}}
201-
202-
}
203-
204-
#endif //#ifdef INTEROP_MODE

0 commit comments

Comments
 (0)