https://github.com/carlosgalvezp updated https://github.com/llvm/llvm-project/pull/140520
>From 35769db674fc2ebe7c0dda9ed329806b8b059414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= <carlos.gal...@zenseact.com> Date: Mon, 19 May 2025 09:35:30 +0000 Subject: [PATCH 1/2] [clang-tidy] Do not flag strerror in concurrency-mt-unsafe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docs of the check state: > Glibc’s list is compiled from GNU web documentation with a search for MT-Safe > tag And strerror fulfills exactly that: https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html > Function: char * strerror (int errnum) > Preliminary: | MT-Safe | AS-Unsafe heap i18n | AC-Unsafe mem | See POSIX > Safety Concepts. So concurrency-mt-unsafe should not flag it. Fixes #140515 --- clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp | 1 - clang-tools-extra/docs/ReleaseNotes.rst | 4 ++++ .../test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp index acffaa30d418e..cf076bb40484f 100644 --- a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp +++ b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp @@ -153,7 +153,6 @@ static const clang::StringRef GlibcFunctions[] = { "::sigsuspend", "::sleep", "::srand48", - "::strerror", "::strsignal", "::strtok", "::tcflow", diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 9b29ab12e1bfa..bd78b26b583c8 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -172,6 +172,10 @@ Changes in existing checks <clang-tidy/checks/cert/err33-c>` check by fixing false positives when a function name is just prefixed with a targeted function name. +- Improved :doc:`concurrency-mt-unsafe + <clang-tidy/checks/concurrency/mt-unsafe>` check by fixing a false positive + where `strerror` was flagged as MT-unsafe. + - Improved :doc:`misc-const-correctness <clang-tidy/checks/misc/const-correctness>` check by adding the option `AllowedTypes`, that excludes specified types from const-correctness diff --git a/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp b/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp index 8b137de005a47..14d1912683795 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp @@ -3,6 +3,7 @@ extern unsigned int sleep (unsigned int __seconds); extern int *gmtime (const int *__timer); extern char *dirname (char *__path); +extern char *strerror(int errnum); void foo() { sleep(2); @@ -12,4 +13,6 @@ void foo() { // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe] dirname(nullptr); + + strerror(0); } >From 146f90ab68454f7b69225783a7d001164514ccdf Mon Sep 17 00:00:00 2001 From: Carlos Galvez <carlosgalv...@gmail.com> Date: Mon, 19 May 2025 16:38:31 +0200 Subject: [PATCH 2/2] Update clang-tools-extra/docs/ReleaseNotes.rst Co-authored-by: EugeneZelenko <eugene.zele...@gmail.com> --- clang-tools-extra/docs/ReleaseNotes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index bd78b26b583c8..99e07ad10bd6d 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -174,7 +174,7 @@ Changes in existing checks - Improved :doc:`concurrency-mt-unsafe <clang-tidy/checks/concurrency/mt-unsafe>` check by fixing a false positive - where `strerror` was flagged as MT-unsafe. + where ``strerror`` was flagged as MT-unsafe. - Improved :doc:`misc-const-correctness <clang-tidy/checks/misc/const-correctness>` check by adding the option _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits