summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp136
1 files changed, 0 insertions, 136 deletions
diff --git a/clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp b/clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp
deleted file mode 100644
index 91867bd489e..00000000000
--- a/clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \
-// RUN: -- -std=c++11
-
-#define __STDC_LIB_EXT1__ 1
-#define __STDC_WANT_LIB_EXT1__ 1
-
-typedef unsigned int size_t;
-typedef int errno_t;
-size_t wcslen(const wchar_t *);
-void *malloc(size_t);
-void *realloc(void *, size_t);
-
-template <size_t size>
-errno_t wcsncpy_s(wchar_t (&dest)[size], const wchar_t *src, size_t length);
-errno_t wcsncpy_s(wchar_t *, size_t, const wchar_t *, size_t);
-
-template <size_t size>
-wchar_t *wcsncpy(wchar_t (&dest)[size], const wchar_t *src, size_t length);
-wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t);
-
-template <size_t size>
-errno_t wcscpy_s(wchar_t (&dest)[size], const wchar_t *);
-errno_t wcscpy_s(wchar_t *, size_t, const wchar_t *);
-
-template <size_t size>
-wchar_t *wcscpy(wchar_t (&dest)[size], const wchar_t *);
-wchar_t *wcscpy(wchar_t *, const wchar_t *);
-
-errno_t wmemcpy_s(wchar_t *, size_t, const wchar_t *, size_t);
-wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t);
-
-
-//===----------------------------------------------------------------------===//
-// wmemcpy() - destination array tests
-//===----------------------------------------------------------------------===//
-
-void bad_wmemcpy_known_dest(const wchar_t *src) {
- wchar_t dest01[13];
- wmemcpy(dest01, src, wcslen(src));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
- // CHECK-FIXES: wchar_t dest01[14];
- // CHECK-FIXES-NEXT: wcscpy_s(dest01, src);
-}
-
-void good_wmemcpy_known_dest(const wchar_t *src) {
- wchar_t dst01[14];
- wcscpy_s(dst01, src);
-}
-
-//===----------------------------------------------------------------------===//
-// wmemcpy() - length tests
-//===----------------------------------------------------------------------===//
-
-void bad_wmemcpy_full_source_length(const wchar_t *src) {
- wchar_t dest20[13];
- wmemcpy(dest20, src, wcslen(src));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
- // CHECK-FIXES: wchar_t dest20[14];
- // CHECK-FIXES-NEXT: wcscpy_s(dest20, src);
-}
-
-void good_wmemcpy_full_source_length(const wchar_t *src) {
- wchar_t dst20[14];
- wcscpy_s(dst20, src);
-}
-
-void bad_wmemcpy_partial_source_length(const wchar_t *src) {
- wchar_t dest21[13];
- wmemcpy(dest21, src, wcslen(src) - 1);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
- // CHECK-FIXES: wchar_t dest21[14];
- // CHECK-FIXES-NEXT: wcsncpy_s(dest21, src, wcslen(src) - 1);
-}
-
-void good_wmemcpy_partial_source_length(const wchar_t *src) {
- wchar_t dst21[14];
- wcsncpy_s(dst21, src, wcslen(src) - 1);
-}
-
-//===----------------------------------------------------------------------===//
-// wmemcpy_s() - destination array tests
-//===----------------------------------------------------------------------===//
-
-void bad_wmemcpy_s_unknown_dest(wchar_t *dest40, const wchar_t *src) {
- wmemcpy_s(dest40, 13, src, wcslen(src));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
- // CHECK-FIXES: wcscpy_s(dest40, 13, src);
-}
-
-void good_wmemcpy_s_unknown_dest(wchar_t *dst40, const wchar_t *src) {
- wcscpy_s(dst40, 13, src);
-}
-
-void bad_wmemcpy_s_known_dest(const wchar_t *src) {
- wchar_t dest41[13];
- wmemcpy_s(dest41, 13, src, wcslen(src));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
- // CHECK-FIXES: wchar_t dest41[14];
- // CHECK-FIXES-NEXT: wcscpy_s(dest41, src);
-}
-
-void good_wmemcpy_s_known_dest(const wchar_t *src) {
- wchar_t dst41[13];
- wcscpy_s(dst41, src);
-}
-
-//===----------------------------------------------------------------------===//
-// wmemcpy_s() - length tests
-//===----------------------------------------------------------------------===//
-
-void bad_wmemcpy_s_full_source_length(const wchar_t *src) {
- wchar_t dest60[13];
- wmemcpy_s(dest60, 13, src, wcslen(src));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
- // CHECK-FIXES: wchar_t dest60[14];
- // CHECK-FIXES-NEXT: wcscpy_s(dest60, src);
-}
-
-void good_wmemcpy_s_full_source_length(const wchar_t *src) {
- wchar_t dst60[13];
- wcscpy_s(dst60, src);
-}
-
-void bad_wmemcpy_s_partial_source_length(const wchar_t *src) {
- wchar_t dest61[13];
- wmemcpy_s(dest61, 13, src, wcslen(src) - 1);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
- // CHECK-FIXES: wchar_t dest61[14];
- // CHECK-FIXES-NEXT: wcsncpy_s(dest61, src, wcslen(src) - 1);
-}
-
-void good_wmemcpy_s_partial_source_length(const wchar_t *src) {
- wchar_t dst61[13];
- wcsncpy_s(dst61, src, wcslen(src) - 1);
-}
-
OpenPOWER on IntegriCloud