public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] libstdc++: Fix clang analyzer suppression [PR 98605]
Date: Fri, 23 Apr 2021 10:38:04 +0000 (GMT)	[thread overview]
Message-ID: <20210423103804.B09ED3A77044@sourceware.org> (raw)

https://gcc.gnu.org/g:204d104dc262f28ec05e09e9123dcc7aa50067d0

commit 204d104dc262f28ec05e09e9123dcc7aa50067d0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jan 13 11:03:58 2021 +0000

    libstdc++: Fix clang analyzer suppression [PR 98605]
    
    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.
    
    (cherry picked from commit 8d3636923a309074eb19240ebaa30c1a0801eaaf)

Diff:
---
 libstdc++-v3/include/std/mutex | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 71e915cc5a0..8476baa24ca 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -673,7 +673,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());
@@ -688,12 +688,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);
     }


                 reply	other threads:[~2021-04-23 10:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210423103804.B09ED3A77044@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).