-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Ensure functions are anchored in the global namespace (for cert-err-33) #99380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The regular expressions match functions that aren't anchored in the global namespace. For example "::remove" matches and object with a "removeXyz" method. This change is to remove these false positives
Merge from llvm
@llvm/pr-subscribers-clang-tidy Author: None (matthew-f) ChangesThe regular expressions match functions that aren't anchored in the global namespace. For example Patch is 23.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/99380.diff 1 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index ffb62b409b29b..8b5be9cd95f76 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -49,183 +49,183 @@ namespace {
// with NULL argument and in this case the check is not applicable:
// `mblen, mbrlen, mbrtowc, mbtowc, wctomb, wctomb_s`.
// FIXME: The check can be improved to handle such cases.
-const llvm::StringRef CertErr33CCheckedFunctions = "::aligned_alloc;"
- "::asctime_s;"
- "::at_quick_exit;"
- "::atexit;"
- "::bsearch;"
- "::bsearch_s;"
- "::btowc;"
- "::c16rtomb;"
- "::c32rtomb;"
- "::calloc;"
- "::clock;"
- "::cnd_broadcast;"
- "::cnd_init;"
- "::cnd_signal;"
- "::cnd_timedwait;"
- "::cnd_wait;"
- "::ctime_s;"
- "::fclose;"
- "::fflush;"
- "::fgetc;"
- "::fgetpos;"
- "::fgets;"
- "::fgetwc;"
- "::fopen;"
- "::fopen_s;"
- "::fprintf;"
- "::fprintf_s;"
- "::fputc;"
- "::fputs;"
- "::fputwc;"
- "::fputws;"
- "::fread;"
- "::freopen;"
- "::freopen_s;"
- "::fscanf;"
- "::fscanf_s;"
- "::fseek;"
- "::fsetpos;"
- "::ftell;"
- "::fwprintf;"
- "::fwprintf_s;"
- "::fwrite;"
- "::fwscanf;"
- "::fwscanf_s;"
- "::getc;"
- "::getchar;"
- "::getenv;"
- "::getenv_s;"
- "::gets_s;"
- "::getwc;"
- "::getwchar;"
- "::gmtime;"
- "::gmtime_s;"
- "::localtime;"
- "::localtime_s;"
- "::malloc;"
- "::mbrtoc16;"
- "::mbrtoc32;"
- "::mbsrtowcs;"
- "::mbsrtowcs_s;"
- "::mbstowcs;"
- "::mbstowcs_s;"
- "::memchr;"
- "::mktime;"
- "::mtx_init;"
- "::mtx_lock;"
- "::mtx_timedlock;"
- "::mtx_trylock;"
- "::mtx_unlock;"
- "::printf_s;"
- "::putc;"
- "::putwc;"
- "::raise;"
- "::realloc;"
- "::remove;"
- "::rename;"
- "::scanf;"
- "::scanf_s;"
- "::setlocale;"
- "::setvbuf;"
- "::signal;"
- "::snprintf;"
- "::snprintf_s;"
- "::sprintf;"
- "::sprintf_s;"
- "::sscanf;"
- "::sscanf_s;"
- "::strchr;"
- "::strerror_s;"
- "::strftime;"
- "::strpbrk;"
- "::strrchr;"
- "::strstr;"
- "::strtod;"
- "::strtof;"
- "::strtoimax;"
- "::strtok;"
- "::strtok_s;"
- "::strtol;"
- "::strtold;"
- "::strtoll;"
- "::strtoul;"
- "::strtoull;"
- "::strtoumax;"
- "::strxfrm;"
- "::swprintf;"
- "::swprintf_s;"
- "::swscanf;"
- "::swscanf_s;"
- "::thrd_create;"
- "::thrd_detach;"
- "::thrd_join;"
- "::thrd_sleep;"
- "::time;"
- "::timespec_get;"
- "::tmpfile;"
- "::tmpfile_s;"
- "::tmpnam;"
- "::tmpnam_s;"
- "::tss_create;"
- "::tss_get;"
- "::tss_set;"
- "::ungetc;"
- "::ungetwc;"
- "::vfprintf;"
- "::vfprintf_s;"
- "::vfscanf;"
- "::vfscanf_s;"
- "::vfwprintf;"
- "::vfwprintf_s;"
- "::vfwscanf;"
- "::vfwscanf_s;"
- "::vprintf_s;"
- "::vscanf;"
- "::vscanf_s;"
- "::vsnprintf;"
- "::vsnprintf_s;"
- "::vsprintf;"
- "::vsprintf_s;"
- "::vsscanf;"
- "::vsscanf_s;"
- "::vswprintf;"
- "::vswprintf_s;"
- "::vswscanf;"
- "::vswscanf_s;"
- "::vwprintf_s;"
- "::vwscanf;"
- "::vwscanf_s;"
- "::wcrtomb;"
- "::wcschr;"
- "::wcsftime;"
- "::wcspbrk;"
- "::wcsrchr;"
- "::wcsrtombs;"
- "::wcsrtombs_s;"
- "::wcsstr;"
- "::wcstod;"
- "::wcstof;"
- "::wcstoimax;"
- "::wcstok;"
- "::wcstok_s;"
- "::wcstol;"
- "::wcstold;"
- "::wcstoll;"
- "::wcstombs;"
- "::wcstombs_s;"
- "::wcstoul;"
- "::wcstoull;"
- "::wcstoumax;"
- "::wcsxfrm;"
- "::wctob;"
- "::wctrans;"
- "::wctype;"
- "::wmemchr;"
- "::wprintf_s;"
- "::wscanf;"
- "::wscanf_s;";
+const llvm::StringRef CertErr33CCheckedFunctions = "^::aligned_alloc;"
+ "^::asctime_s;"
+ "^::at_quick_exit;"
+ "^::atexit;"
+ "^::bsearch;"
+ "^::bsearch_s;"
+ "^::btowc;"
+ "^::c16rtomb;"
+ "^::c32rtomb;"
+ "^::calloc;"
+ "^::clock;"
+ "^::cnd_broadcast;"
+ "^::cnd_init;"
+ "^::cnd_signal;"
+ "^::cnd_timedwait;"
+ "^::cnd_wait;"
+ "^::ctime_s;"
+ "^::fclose;"
+ "^::fflush;"
+ "^::fgetc;"
+ "^::fgetpos;"
+ "^::fgets;"
+ "^::fgetwc;"
+ "^::fopen;"
+ "^::fopen_s;"
+ "^::fprintf;"
+ "^::fprintf_s;"
+ "^::fputc;"
+ "^::fputs;"
+ "^::fputwc;"
+ "^::fputws;"
+ "^::fread;"
+ "^::freopen;"
+ "^::freopen_s;"
+ "^::fscanf;"
+ "^::fscanf_s;"
+ "^::fseek;"
+ "^::fsetpos;"
+ "^::ftell;"
+ "^::fwprintf;"
+ "^::fwprintf_s;"
+ "^::fwrite;"
+ "^::fwscanf;"
+ "^::fwscanf_s;"
+ "^::getc;"
+ "^::getchar;"
+ "^::getenv;"
+ "^::getenv_s;"
+ "^::gets_s;"
+ "^::getwc;"
+ "^::getwchar;"
+ "^::gmtime;"
+ "^::gmtime_s;"
+ "^::localtime;"
+ "^::localtime_s;"
+ "^::malloc;"
+ "^::mbrtoc16;"
+ "^::mbrtoc32;"
+ "^::mbsrtowcs;"
+ "^::mbsrtowcs_s;"
+ "^::mbstowcs;"
+ "^::mbstowcs_s;"
+ "^::memchr;"
+ "^::mktime;"
+ "^::mtx_init;"
+ "^::mtx_lock;"
+ "^::mtx_timedlock;"
+ "^::mtx_trylock;"
+ "^::mtx_unlock;"
+ "^::printf_s;"
+ "^::putc;"
+ "^::putwc;"
+ "^::raise;"
+ "^::realloc;"
+ "^::remove;"
+ "^::rename;"
+ "^::scanf;"
+ "^::scanf_s;"
+ "^::setlocale;"
+ "^::setvbuf;"
+ "^::signal;"
+ "^::snprintf;"
+ "^::snprintf_s;"
+ "^::sprintf;"
+ "^::sprintf_s;"
+ "^::sscanf;"
+ "^::sscanf_s;"
+ "^::strchr;"
+ "^::strerror_s;"
+ "^::strftime;"
+ "^::strpbrk;"
+ "^::strrchr;"
+ "^::strstr;"
+ "^::strtod;"
+ "^::strtof;"
+ "^::strtoimax;"
+ "^::strtok;"
+ "^::strtok_s;"
+ "^::strtol;"
+ "^::strtold;"
+ "^::strtoll;"
+ "^::strtoul;"
+ "^::strtoull;"
+ "^::strtoumax;"
+ "^::strxfrm;"
+ "^::swprintf;"
+ "^::swprintf_s;"
+ "^::swscanf;"
+ "^::swscanf_s;"
+ "^::thrd_create;"
+ "^::thrd_detach;"
+ "^::thrd_join;"
+ "^::thrd_sleep;"
+ "^::time;"
+ "^::timespec_get;"
+ "^::tmpfile;"
+ "^::tmpfile_s;"
+ "^::tmpnam;"
+ "^::tmpnam_s;"
+ "^::tss_create;"
+ "^::tss_get;"
+ "^::tss_set;"
+ "^::ungetc;"
+ "^::ungetwc;"
+ "^::vfprintf;"
+ ...
[truncated]
|
@llvm/pr-subscribers-clang-tools-extra Author: None (matthew-f) ChangesThe regular expressions match functions that aren't anchored in the global namespace. For example Patch is 23.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/99380.diff 1 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index ffb62b409b29b..8b5be9cd95f76 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -49,183 +49,183 @@ namespace {
// with NULL argument and in this case the check is not applicable:
// `mblen, mbrlen, mbrtowc, mbtowc, wctomb, wctomb_s`.
// FIXME: The check can be improved to handle such cases.
-const llvm::StringRef CertErr33CCheckedFunctions = "::aligned_alloc;"
- "::asctime_s;"
- "::at_quick_exit;"
- "::atexit;"
- "::bsearch;"
- "::bsearch_s;"
- "::btowc;"
- "::c16rtomb;"
- "::c32rtomb;"
- "::calloc;"
- "::clock;"
- "::cnd_broadcast;"
- "::cnd_init;"
- "::cnd_signal;"
- "::cnd_timedwait;"
- "::cnd_wait;"
- "::ctime_s;"
- "::fclose;"
- "::fflush;"
- "::fgetc;"
- "::fgetpos;"
- "::fgets;"
- "::fgetwc;"
- "::fopen;"
- "::fopen_s;"
- "::fprintf;"
- "::fprintf_s;"
- "::fputc;"
- "::fputs;"
- "::fputwc;"
- "::fputws;"
- "::fread;"
- "::freopen;"
- "::freopen_s;"
- "::fscanf;"
- "::fscanf_s;"
- "::fseek;"
- "::fsetpos;"
- "::ftell;"
- "::fwprintf;"
- "::fwprintf_s;"
- "::fwrite;"
- "::fwscanf;"
- "::fwscanf_s;"
- "::getc;"
- "::getchar;"
- "::getenv;"
- "::getenv_s;"
- "::gets_s;"
- "::getwc;"
- "::getwchar;"
- "::gmtime;"
- "::gmtime_s;"
- "::localtime;"
- "::localtime_s;"
- "::malloc;"
- "::mbrtoc16;"
- "::mbrtoc32;"
- "::mbsrtowcs;"
- "::mbsrtowcs_s;"
- "::mbstowcs;"
- "::mbstowcs_s;"
- "::memchr;"
- "::mktime;"
- "::mtx_init;"
- "::mtx_lock;"
- "::mtx_timedlock;"
- "::mtx_trylock;"
- "::mtx_unlock;"
- "::printf_s;"
- "::putc;"
- "::putwc;"
- "::raise;"
- "::realloc;"
- "::remove;"
- "::rename;"
- "::scanf;"
- "::scanf_s;"
- "::setlocale;"
- "::setvbuf;"
- "::signal;"
- "::snprintf;"
- "::snprintf_s;"
- "::sprintf;"
- "::sprintf_s;"
- "::sscanf;"
- "::sscanf_s;"
- "::strchr;"
- "::strerror_s;"
- "::strftime;"
- "::strpbrk;"
- "::strrchr;"
- "::strstr;"
- "::strtod;"
- "::strtof;"
- "::strtoimax;"
- "::strtok;"
- "::strtok_s;"
- "::strtol;"
- "::strtold;"
- "::strtoll;"
- "::strtoul;"
- "::strtoull;"
- "::strtoumax;"
- "::strxfrm;"
- "::swprintf;"
- "::swprintf_s;"
- "::swscanf;"
- "::swscanf_s;"
- "::thrd_create;"
- "::thrd_detach;"
- "::thrd_join;"
- "::thrd_sleep;"
- "::time;"
- "::timespec_get;"
- "::tmpfile;"
- "::tmpfile_s;"
- "::tmpnam;"
- "::tmpnam_s;"
- "::tss_create;"
- "::tss_get;"
- "::tss_set;"
- "::ungetc;"
- "::ungetwc;"
- "::vfprintf;"
- "::vfprintf_s;"
- "::vfscanf;"
- "::vfscanf_s;"
- "::vfwprintf;"
- "::vfwprintf_s;"
- "::vfwscanf;"
- "::vfwscanf_s;"
- "::vprintf_s;"
- "::vscanf;"
- "::vscanf_s;"
- "::vsnprintf;"
- "::vsnprintf_s;"
- "::vsprintf;"
- "::vsprintf_s;"
- "::vsscanf;"
- "::vsscanf_s;"
- "::vswprintf;"
- "::vswprintf_s;"
- "::vswscanf;"
- "::vswscanf_s;"
- "::vwprintf_s;"
- "::vwscanf;"
- "::vwscanf_s;"
- "::wcrtomb;"
- "::wcschr;"
- "::wcsftime;"
- "::wcspbrk;"
- "::wcsrchr;"
- "::wcsrtombs;"
- "::wcsrtombs_s;"
- "::wcsstr;"
- "::wcstod;"
- "::wcstof;"
- "::wcstoimax;"
- "::wcstok;"
- "::wcstok_s;"
- "::wcstol;"
- "::wcstold;"
- "::wcstoll;"
- "::wcstombs;"
- "::wcstombs_s;"
- "::wcstoul;"
- "::wcstoull;"
- "::wcstoumax;"
- "::wcsxfrm;"
- "::wctob;"
- "::wctrans;"
- "::wctype;"
- "::wmemchr;"
- "::wprintf_s;"
- "::wscanf;"
- "::wscanf_s;";
+const llvm::StringRef CertErr33CCheckedFunctions = "^::aligned_alloc;"
+ "^::asctime_s;"
+ "^::at_quick_exit;"
+ "^::atexit;"
+ "^::bsearch;"
+ "^::bsearch_s;"
+ "^::btowc;"
+ "^::c16rtomb;"
+ "^::c32rtomb;"
+ "^::calloc;"
+ "^::clock;"
+ "^::cnd_broadcast;"
+ "^::cnd_init;"
+ "^::cnd_signal;"
+ "^::cnd_timedwait;"
+ "^::cnd_wait;"
+ "^::ctime_s;"
+ "^::fclose;"
+ "^::fflush;"
+ "^::fgetc;"
+ "^::fgetpos;"
+ "^::fgets;"
+ "^::fgetwc;"
+ "^::fopen;"
+ "^::fopen_s;"
+ "^::fprintf;"
+ "^::fprintf_s;"
+ "^::fputc;"
+ "^::fputs;"
+ "^::fputwc;"
+ "^::fputws;"
+ "^::fread;"
+ "^::freopen;"
+ "^::freopen_s;"
+ "^::fscanf;"
+ "^::fscanf_s;"
+ "^::fseek;"
+ "^::fsetpos;"
+ "^::ftell;"
+ "^::fwprintf;"
+ "^::fwprintf_s;"
+ "^::fwrite;"
+ "^::fwscanf;"
+ "^::fwscanf_s;"
+ "^::getc;"
+ "^::getchar;"
+ "^::getenv;"
+ "^::getenv_s;"
+ "^::gets_s;"
+ "^::getwc;"
+ "^::getwchar;"
+ "^::gmtime;"
+ "^::gmtime_s;"
+ "^::localtime;"
+ "^::localtime_s;"
+ "^::malloc;"
+ "^::mbrtoc16;"
+ "^::mbrtoc32;"
+ "^::mbsrtowcs;"
+ "^::mbsrtowcs_s;"
+ "^::mbstowcs;"
+ "^::mbstowcs_s;"
+ "^::memchr;"
+ "^::mktime;"
+ "^::mtx_init;"
+ "^::mtx_lock;"
+ "^::mtx_timedlock;"
+ "^::mtx_trylock;"
+ "^::mtx_unlock;"
+ "^::printf_s;"
+ "^::putc;"
+ "^::putwc;"
+ "^::raise;"
+ "^::realloc;"
+ "^::remove;"
+ "^::rename;"
+ "^::scanf;"
+ "^::scanf_s;"
+ "^::setlocale;"
+ "^::setvbuf;"
+ "^::signal;"
+ "^::snprintf;"
+ "^::snprintf_s;"
+ "^::sprintf;"
+ "^::sprintf_s;"
+ "^::sscanf;"
+ "^::sscanf_s;"
+ "^::strchr;"
+ "^::strerror_s;"
+ "^::strftime;"
+ "^::strpbrk;"
+ "^::strrchr;"
+ "^::strstr;"
+ "^::strtod;"
+ "^::strtof;"
+ "^::strtoimax;"
+ "^::strtok;"
+ "^::strtok_s;"
+ "^::strtol;"
+ "^::strtold;"
+ "^::strtoll;"
+ "^::strtoul;"
+ "^::strtoull;"
+ "^::strtoumax;"
+ "^::strxfrm;"
+ "^::swprintf;"
+ "^::swprintf_s;"
+ "^::swscanf;"
+ "^::swscanf_s;"
+ "^::thrd_create;"
+ "^::thrd_detach;"
+ "^::thrd_join;"
+ "^::thrd_sleep;"
+ "^::time;"
+ "^::timespec_get;"
+ "^::tmpfile;"
+ "^::tmpfile_s;"
+ "^::tmpnam;"
+ "^::tmpnam_s;"
+ "^::tss_create;"
+ "^::tss_get;"
+ "^::tss_set;"
+ "^::ungetc;"
+ "^::ungetwc;"
+ "^::vfprintf;"
+ ...
[truncated]
|
|
…or cert-err-33) (#99380) Summary: The regular expressions match functions that aren't anchored in the global namespace. For example `::remove` matches any object with a `removeXyz` method. This change is to remove these false positives Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251178
The regular expressions match functions that aren't anchored in the global namespace. For example
::remove
matches any object with aremoveXyz
method. This change is to remove these false positives