]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix clang analyzer suppression [PR 98605]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 13 Jan 2021 11:03:58 +0000 (11:03 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 13 Jan 2021 13:06:06 +0000 (13:06 +0000)
The fix for PR libstdc++/82481 should only have applied for targets
where _GLIBCXX_HAVE_TLS is defined. Because it was also done for non-TLS
targets, it isn't possible to use clang's analyzers on non-TLS targets
if the code uses <mutex>. This fixes it by using a NOLINT comment on
the relevant line instead of testing #ifdef __clang_analyzer__ and
compiling different code when analyzing.

I'm not actually able to reproduce the analyzer warning with the tools
from Clang 10.0.1 so I'm not going to try to make the suppression more
specific with NOLINTNEXTLINE(clang-analyzer-code.StackAddressEscape).

libstdc++-v3/ChangeLog:

PR libstdc++/98605
* include/std/mutex (call_once): Use NOLINT to suppress clang
analyzer warnings.

libstdc++-v3/include/std/mutex

index 12b7e548d179c3a2cb0ed65b6e113031f11293f6..3c619f87040bc84387cb894869dc347a3a6b931d 100644 (file)
@@ -718,7 +718,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                        std::forward<_Args>(__args)...);
       };
 #ifdef _GLIBCXX_HAVE_TLS
-      __once_callable = std::__addressof(__callable);
+      __once_callable = std::__addressof(__callable); // NOLINT: PR 82481
       __once_call = []{ (*(decltype(__callable)*)__once_callable)(); };
 #else
       unique_lock<mutex> __functor_lock(__get_once_mutex());
@@ -733,12 +733,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         __set_once_functor_lock_ptr(0);
 #endif
 
-#ifdef __clang_analyzer__
-      // PR libstdc++/82481
-      __once_callable = nullptr;
-      __once_call = nullptr;
-#endif
-
       if (__e)
        __throw_system_error(__e);
     }