[clang-tools-extra] c736ca8 - [clang-tidy] Ensure functions are anchored in the global namespace (#99084)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 17 10:05:34 PDT 2024
Author: matthew-f
Date: 2024-07-17T19:05:30+02:00
New Revision: c736ca85c38ce9c30a2286382d8023604f34f9e8
URL: https://github.com/llvm/llvm-project/commit/c736ca85c38ce9c30a2286382d8023604f34f9e8
DIFF: https://github.com/llvm/llvm-project/commit/c736ca85c38ce9c30a2286382d8023604f34f9e8.diff
LOG: [clang-tidy] Ensure functions are anchored in the global namespace (#99084)
The regular expressions match functions that aren't anchored in the
global namespace. For example `::connect` matches `QObject::connect`
This change is to remove these false positives
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
index 73373147e96fc..955a9b94dfaf6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -48,97 +48,97 @@ UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
CheckedFunctions(utils::options::parseStringList(
- Options.get("CheckedFunctions", "::std::async$;"
- "::std::launder$;"
- "::std::remove$;"
- "::std::remove_if$;"
- "::std::unique$;"
- "::std::unique_ptr::release$;"
- "::std::basic_string::empty$;"
- "::std::vector::empty$;"
- "::std::back_inserter$;"
- "::std::distance$;"
- "::std::find$;"
- "::std::find_if$;"
- "::std::inserter$;"
- "::std::lower_bound$;"
- "::std::make_pair$;"
- "::std::map::count$;"
- "::std::map::find$;"
- "::std::map::lower_bound$;"
- "::std::multimap::equal_range$;"
- "::std::multimap::upper_bound$;"
- "::std::set::count$;"
- "::std::set::find$;"
- "::std::setfill$;"
- "::std::setprecision$;"
- "::std::setw$;"
- "::std::upper_bound$;"
- "::std::vector::at$;"
+ Options.get("CheckedFunctions", "^::std::async$;"
+ "^::std::launder$;"
+ "^::std::remove$;"
+ "^::std::remove_if$;"
+ "^::std::unique$;"
+ "^::std::unique_ptr::release$;"
+ "^::std::basic_string::empty$;"
+ "^::std::vector::empty$;"
+ "^::std::back_inserter$;"
+ "^::std::distance$;"
+ "^::std::find$;"
+ "^::std::find_if$;"
+ "^::std::inserter$;"
+ "^::std::lower_bound$;"
+ "^::std::make_pair$;"
+ "^::std::map::count$;"
+ "^::std::map::find$;"
+ "^::std::map::lower_bound$;"
+ "^::std::multimap::equal_range$;"
+ "^::std::multimap::upper_bound$;"
+ "^::std::set::count$;"
+ "^::std::set::find$;"
+ "^::std::setfill$;"
+ "^::std::setprecision$;"
+ "^::std::setw$;"
+ "^::std::upper_bound$;"
+ "^::std::vector::at$;"
// C standard library
- "::bsearch$;"
- "::ferror$;"
- "::feof$;"
- "::isalnum$;"
- "::isalpha$;"
- "::isblank$;"
- "::iscntrl$;"
- "::isdigit$;"
- "::isgraph$;"
- "::islower$;"
- "::isprint$;"
- "::ispunct$;"
- "::isspace$;"
- "::isupper$;"
- "::iswalnum$;"
- "::iswprint$;"
- "::iswspace$;"
- "::isxdigit$;"
- "::memchr$;"
- "::memcmp$;"
- "::strcmp$;"
- "::strcoll$;"
- "::strncmp$;"
- "::strpbrk$;"
- "::strrchr$;"
- "::strspn$;"
- "::strstr$;"
- "::wcscmp$;"
+ "^::bsearch$;"
+ "^::ferror$;"
+ "^::feof$;"
+ "^::isalnum$;"
+ "^::isalpha$;"
+ "^::isblank$;"
+ "^::iscntrl$;"
+ "^::isdigit$;"
+ "^::isgraph$;"
+ "^::islower$;"
+ "^::isprint$;"
+ "^::ispunct$;"
+ "^::isspace$;"
+ "^::isupper$;"
+ "^::iswalnum$;"
+ "^::iswprint$;"
+ "^::iswspace$;"
+ "^::isxdigit$;"
+ "^::memchr$;"
+ "^::memcmp$;"
+ "^::strcmp$;"
+ "^::strcoll$;"
+ "^::strncmp$;"
+ "^::strpbrk$;"
+ "^::strrchr$;"
+ "^::strspn$;"
+ "^::strstr$;"
+ "^::wcscmp$;"
// POSIX
- "::access$;"
- "::bind$;"
- "::connect$;"
- "::
diff time$;"
- "::dlsym$;"
- "::fnmatch$;"
- "::getaddrinfo$;"
- "::getopt$;"
- "::htonl$;"
- "::htons$;"
- "::iconv_open$;"
- "::inet_addr$;"
- "::isascii$;"
- "::isatty$;"
- "::mmap$;"
- "::newlocale$;"
- "::openat$;"
- "::pathconf$;"
- "::pthread_equal$;"
- "::pthread_getspecific$;"
- "::pthread_mutex_trylock$;"
- "::readdir$;"
- "::readlink$;"
- "::recvmsg$;"
- "::regexec$;"
- "::scandir$;"
- "::semget$;"
- "::setjmp$;"
- "::shm_open$;"
- "::shmget$;"
- "::sigismember$;"
- "::strcasecmp$;"
- "::strsignal$;"
- "::ttyname"))),
+ "^::access$;"
+ "^::bind$;"
+ "^::connect$;"
+ "^::
diff time$;"
+ "^::dlsym$;"
+ "^::fnmatch$;"
+ "^::getaddrinfo$;"
+ "^::getopt$;"
+ "^::htonl$;"
+ "^::htons$;"
+ "^::iconv_open$;"
+ "^::inet_addr$;"
+ "^::isascii$;"
+ "^::isatty$;"
+ "^::mmap$;"
+ "^::newlocale$;"
+ "^::openat$;"
+ "^::pathconf$;"
+ "^::pthread_equal$;"
+ "^::pthread_getspecific$;"
+ "^::pthread_mutex_trylock$;"
+ "^::readdir$;"
+ "^::readlink$;"
+ "^::recvmsg$;"
+ "^::regexec$;"
+ "^::scandir$;"
+ "^::semget$;"
+ "^::setjmp$;"
+ "^::shm_open$;"
+ "^::shmget$;"
+ "^::sigismember$;"
+ "^::strcasecmp$;"
+ "^::strsignal$;"
+ "^::ttyname"))),
CheckedReturnTypes(utils::options::parseStringList(
Options.get("CheckedReturnTypes", "::std::error_code$;"
"::std::error_condition$;"
More information about the cfe-commits
mailing list