From a89e20614e01f60dda8fbd0cc797dbb06caeee3d Mon Sep 17 00:00:00 2001
From: Shaun <shaun.roe@cern.ch>
Date: Tue, 15 Apr 2025 11:32:33 +0200
Subject: [PATCH] solve remaining warnings

---
 .../GeoModelHelpers/src/GeoDeDuplicator.cxx     | 10 ++++++++--
 .../GeoModelHelpers/src/cloneVolume.cxx         | 17 +++++++++++++----
 .../src/getChildNodesWithTrf.cxx                | 12 +++++++++---
 .../GeoModelHelpers/tests/testFullPhysVol.cxx   | 11 ++++++++++-
 .../GeoModelKernel/GeoAnnulusSurface.h          |  6 +++---
 .../GeoModelKernel/GeoCountVolAction.h          |  8 ++++----
 .../GeoModelKernel/GeoDiamondSurface.h          |  6 +++---
 7 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx b/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx
index 0e0aba4cf..dff9d8767 100644
--- a/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx
+++ b/GeoModelCore/GeoModelHelpers/src/GeoDeDuplicator.cxx
@@ -12,6 +12,12 @@ GeoDeDuplicator::GeoIdMap GeoDeDuplicator::s_geoIds{};
 
 namespace {
     std::mutex s_mutex{};
+    ///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
+    template<class A, class B>
+    bool
+    typeis(B && b){
+      return typeid(A) == typeid(b);
+    }
 }
 
 void GeoDeDuplicator::setShapeDeDuplication(bool enable){
@@ -124,10 +130,10 @@ PVLink GeoDeDuplicator::clone(PVConstLink cloneMe) const {
     for(unsigned int chNode =0; chNode < cloneMe->getNChildNodes(); ++chNode) {
         GeoIntrusivePtr<const GeoGraphNode>node{*cloneMe->getChildNode(chNode)};
         /** transform nodes */
-        if (typeid(*node) == typeid(GeoAlignableTransform)) {
+        if (typeis<GeoAlignableTransform>(*node)) {
             const auto geoTrf = dynamic_pointer_cast<const GeoAlignableTransform>(node);
             newVol->add(make_intrusive<GeoAlignableTransform>(geoTrf->getDefTransform()));
-        } else if (typeid(*node) == typeid(GeoTransform)) {
+        } else if (typeis<GeoTransform>(*node)) {
             const auto geoTrf = dynamic_pointer_cast<const GeoTransform>(node);
             auto geoTrfNonConst = const_pointer_cast(geoTrf);
             newVol->add(cacheTransform(geoTrfNonConst));
diff --git a/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx b/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx
index 6177229d4..f214a36e0 100644
--- a/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx
+++ b/GeoModelCore/GeoModelHelpers/src/cloneVolume.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 #include "GeoModelHelpers/cloneVolume.h"
 #include "GeoModelHelpers/getChildNodesWithTrf.h"
@@ -7,18 +7,27 @@
 #include "GeoModelKernel/GeoFullPhysVol.h"
 #include "GeoModelKernel/GeoPhysVol.h"
 
+namespace{
+  ///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
+  template<class A, class B>
+  bool
+  typeis(B && b){
+    return typeid(A) == typeid(b);
+  }
+}
+
 PVLink cloneVolume(const PVLink& volume, bool allowShared) {
     PVLink newVolume{volume};
     if (!allowShared || hasFullPhysVolInTree(volume)) {
-        if (typeid(*volume) == typeid(GeoPhysVol)) {
+        if (typeis<GeoPhysVol>(*volume)) {
             newVolume = make_intrusive<GeoPhysVol>(volume->getLogVol());
-        } else if (typeid(*volume) == typeid(GeoFullPhysVol)) {
+        } else if (typeis<GeoFullPhysVol>(*volume)) {
             newVolume = make_intrusive<GeoFullPhysVol>(volume->getLogVol());
         }
         for (unsigned int ch = 0; ch < volume->getNChildNodes(); ++ch){
           const GeoGraphNode* node = (*volume->getChildNode(ch));
           
-          if (typeid(*node) == typeid(GeoPhysVol) || typeid(*node) == typeid(GeoFullPhysVol)) {    
+          if (typeis<GeoPhysVol>(*node) || typeis<GeoFullPhysVol>(*node)) {    
             const GeoVPhysVol* childConstVol{static_cast<const GeoVPhysVol*>(node)};
             GeoVPhysVol* childVol{const_cast<GeoVPhysVol*>(childConstVol)};
             newVolume->add(cloneVolume(childVol, allowShared));
diff --git a/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx b/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx
index f1d8fec4b..11314ae36 100644
--- a/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx
+++ b/GeoModelCore/GeoModelHelpers/src/getChildNodesWithTrf.cxx
@@ -12,6 +12,12 @@
 
 namespace {
     constexpr std::string_view dummyNodeName{"ANON"};
+    ///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
+    template<class A, class B>
+    bool
+    typeis(B && b){
+      return typeid(A) == typeid(b);
+    }
 }
 
 
@@ -20,7 +26,7 @@ namespace {
     volume{curs.getVolume()},
     nodeName{curs.getName()},
     isAlignable{curs.hasAlignableTransform()},
-    isSensitive{typeid(*volume) == typeid(GeoFullPhysVol)},
+    isSensitive{typeis<GeoFullPhysVol>(*volume)},
     volumeId{static_cast<const std::optional<int>&>(curs.getId())} {
     //// Do not specify a node name if it's a dummy one
     if (nodeName == dummyNodeName) {
@@ -95,8 +101,8 @@ std::vector<GeoChildNodeWithTrf> getAllSubVolumes(PVConstLink physVol) {
 }
 
 bool hasFullPhysVolInTree(const PVConstLink& physVol) {
-    if (typeid(*physVol) == typeid(GeoFullPhysVol) ||
-        typeid(*physVol) == typeid(GeoVFullPhysVol)){
+    if (typeis<GeoFullPhysVol>(*physVol) ||
+        typeis<GeoVFullPhysVol>(*physVol)){
         return true;
     }
     for (unsigned int ch = 0; ch < physVol->getNChildVols(); ++ch) {
diff --git a/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx b/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx
index b834b3018..35f7f6a15 100644
--- a/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx
+++ b/GeoModelCore/GeoModelHelpers/tests/testFullPhysVol.cxx
@@ -13,6 +13,15 @@
 #include <GeoModelHelpers/getChildNodesWithTrf.h>
 #include <iostream>
 
+namespace{
+  ///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
+  template<class A>
+  const char*
+  safeTypeIdName(A && a){
+    return typeid(A).name();
+  }
+}
+
 
 int main(int argc, char *argv[]){
     GeoIntrusivePtr<GeoMaterial> material = make_intrusive<GeoMaterial>("Snow", 1.45);
@@ -90,7 +99,7 @@ int main(int argc, char *argv[]){
       std::optional<int> query = cParent->getIdOfChildVol(0);
         if (!query) {
             std::cerr<<__FILE__<<":"<<__LINE__<<" Failed to obtain a valid child volume ID. Expected "<<currentK
-                     <<" "<<typeid(*cParent->getChildVol(0)).name()<<std::endl;
+                     <<" "<<safeTypeIdName(*cParent->getChildVol(0))<<std::endl;
             return EXIT_FAILURE;
         }
         unsigned int parentID = *query;
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h
index 7dc31d3dc..b2f05a204 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoAnnulusSurface.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 /*
@@ -66,11 +66,11 @@ class GeoAnnulusSurface : public GeoVSurfaceShape
       // coming soon!
       //bool isInside(double x, double y) const;
 
-      virtual const std::string & type() const{
+      virtual const std::string & type() const override final{
         return s_classType;
       }
 
-      virtual ShapeType typeID() const{
+      virtual ShapeType typeID() const override final{
         return s_classTypeID;
       }
 
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h
index 0dbf06058..5d04c4931 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoCountVolAction.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef GEOMODELKERNEL_GEOCOUNTVOLACTION_H
@@ -14,13 +14,13 @@ class GeoCountVolAction : public GeoNodeAction
   virtual ~GeoCountVolAction() = default;
 
   //	Handles a physical volume.
-  virtual void handlePhysVol (const GeoPhysVol *);
+  virtual void handlePhysVol (const GeoPhysVol *) override;
   
   //	Handles a physical volume.
-  virtual void handleFullPhysVol (const GeoFullPhysVol *);
+  virtual void handleFullPhysVol (const GeoFullPhysVol *) override;
   
   //	Handles a Serial Transformer
-  virtual void handleSerialTransformer (const GeoSerialTransformer  *st);
+  virtual void handleSerialTransformer (const GeoSerialTransformer  *st) override;
   
   //	Handles a virtual surface.
   virtual void handleVSurface (const GeoVSurface *) override;
diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h
index bcf1b62cd..d3b55e9c9 100644
--- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h
+++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoDiamondSurface.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 /*
@@ -54,11 +54,11 @@ class GeoDiamondSurface : public GeoVSurfaceShape
     return m_YtopHalf;
   }  
 
-  virtual const std::string & type () const{
+  virtual const std::string & type () const override final{
      return s_classType;
   }
 
-  virtual ShapeType typeID () const{
+  virtual ShapeType typeID () const override final{
      return s_classTypeID;
   }
 
-- 
GitLab