From 5e4391108624cc7c1880099ce4e48d18747b5085 Mon Sep 17 00:00:00 2001
From: sss <sss@karma>
Date: Sat, 7 Dec 2024 11:35:42 -0500
Subject: [PATCH 1/2] CheckerGccPlugins: Updates for gcc15.

When testing for the thread-safe attribute, need to check type attributes
in addition to decl attributes.
---
 External/CheckerGccPlugins/src/thread_plugin.cxx |  5 ++++-
 External/CheckerGccPlugins/test/thread7_test.cxx | 11 ++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/External/CheckerGccPlugins/src/thread_plugin.cxx b/External/CheckerGccPlugins/src/thread_plugin.cxx
index cfdb70aa..eee85101 100644
--- a/External/CheckerGccPlugins/src/thread_plugin.cxx
+++ b/External/CheckerGccPlugins/src/thread_plugin.cxx
@@ -293,7 +293,10 @@ void check_attrib_consistency (Attributes_t attribs, tree decl)
 
 bool has_thread_safe_attrib (tree decl)
 {
-  return lookup_attribute ("thread_safe", DECL_ATTRIBUTES (decl));
+  if (lookup_attribute ("thread_safe", DECL_ATTRIBUTES (decl))) {
+    return true;
+  }
+  return lookup_attribute ("thread_safe", TYPE_ATTRIBUTES (TREE_TYPE (decl)));
 }
 
 
diff --git a/External/CheckerGccPlugins/test/thread7_test.cxx b/External/CheckerGccPlugins/test/thread7_test.cxx
index 4c9ee001..d86a492a 100644
--- a/External/CheckerGccPlugins/test/thread7_test.cxx
+++ b/External/CheckerGccPlugins/test/thread7_test.cxx
@@ -1,4 +1,4 @@
-// Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+// Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 // testing check for static/mutable members
 
 #pragma ATLAS check_thread_safety
@@ -58,3 +58,12 @@ struct GaudiTest
   mutable Gaudi::Accumulators::Counter<int, Gaudi::Accumulators::atomicity::full> x2;
   mutable Gaudi::Accumulators::Counter<int, Gaudi::Accumulators::atomicity::none> x3;
 };
+
+
+class TileROD_Decoder
+{
+public:
+  virtual ~TileROD_Decoder();
+  mutable int m_OFWeights[1000] [[ATLAS::thread_safe]];
+
+};
-- 
GitLab


From fc0e5b198a3c9e4834f44c57633a0d7342e7e595 Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Wed, 13 Nov 2024 19:14:51 +0100
Subject: [PATCH 2/2] CheckerGccPlugins: Fix a few cppcheck warnings.

Potential null pointer dereferences.
---
 .../src/callcheck_plugin.cxx                  |  2 +-
 .../CheckerGccPlugins/src/thread_plugin.cxx   | 22 ++++++++++---------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/External/CheckerGccPlugins/src/callcheck_plugin.cxx b/External/CheckerGccPlugins/src/callcheck_plugin.cxx
index dc85352f..e2df3fc7 100644
--- a/External/CheckerGccPlugins/src/callcheck_plugin.cxx
+++ b/External/CheckerGccPlugins/src/callcheck_plugin.cxx
@@ -323,7 +323,7 @@ unsigned int callcheck_pass::callcheck_execute (function* fun)
       // ROOT special case.
       // The ClassDef macro injects this into user classes; the inline
       // definition of this uses static data.
-      if (strcmp (namestr, "CheckTObjectHashConsistency") == 0) {
+      if (namestr && strcmp (namestr, "CheckTObjectHashConsistency") == 0) {
         return 0;
       }
     }
diff --git a/External/CheckerGccPlugins/src/thread_plugin.cxx b/External/CheckerGccPlugins/src/thread_plugin.cxx
index eee85101..2eb499c3 100644
--- a/External/CheckerGccPlugins/src/thread_plugin.cxx
+++ b/External/CheckerGccPlugins/src/thread_plugin.cxx
@@ -1878,16 +1878,18 @@ void check_calls (Attributes_t attribs, gimplePtr stmt, function* fun)
     if (name) {
       const char* namestr = IDENTIFIER_POINTER (name);
 
-      // Skip names starting with __.  Exception: constructors and destructors
-      // will have names like __ct_ and __dt_; don't skip those.
-      if (namestr && namestr[0] == '_' && namestr[1] == '_' &&
-          !startswith (namestr, "__ct_") &&
-          !startswith (namestr, "__dt_"))
-      {
-        return;
+      if (namestr) {
+        // Skip names starting with __.  Exception: constructors and destructors
+        // will have names like __ct_ and __dt_; don't skip those.
+        if (namestr[0] == '_' && namestr[1] == '_' &&
+            !startswith (namestr, "__ct_") &&
+            !startswith (namestr, "__dt_"))
+        {
+          return;
+        }
+        if (strcmp (namestr, "operator delete") == 0) return;
+        if (strcmp (namestr, "operator delete []") == 0) return;
       }
-      if (strcmp (namestr, "operator delete") == 0) return;
-      if (strcmp (namestr, "operator delete []") == 0) return;
     }
     
     Attributes_t fnattribs = get_attributes (fndecl);
@@ -1994,7 +1996,7 @@ unsigned int thread_pass::thread_execute (function* fun)
       // ROOT special case.
       // The ClassDef macro injects this into user classes; the inline
       // definition of this uses static data.
-      if (strcmp (namestr, "CheckTObjectHashConsistency") == 0) {
+      if (namestr && strcmp (namestr, "CheckTObjectHashConsistency") == 0) {
         return 0;
       }
     }
-- 
GitLab