From 05e6e6ee84f41b90efdb933c60841bb85c25cecb Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Thu, 3 Nov 2016 18:45:31 +0100 Subject: [PATCH] First round of fixing Clang compiler and linker problems --- DDCore/include/DD4hep/Conditions.h | 5 ++- DDCore/include/DD4hep/IOV.h | 17 ++++++--- DDCore/include/DD4hep/LCDD.h | 3 +- DDCore/include/DD4hep/LCDDData.h | 4 ++ DDCore/include/DD4hep/ObjectExtensions.h | 6 +++ DDCore/include/DD4hep/OpaqueData.h | 7 +++- DDCore/include/DD4hep/Primitives.h | 4 +- DDCore/src/Evaluator/stack.src | 4 +- DDCore/src/IOV.cpp | 20 +++++----- DDCore/src/LCDDData.cpp | 47 +++++++++++------------- DDCore/src/LCDDImp.cpp | 15 -------- DDCore/src/LCDDImp.h | 4 +- DDCore/src/ObjectExtensions.cpp | 6 +++ DDCore/src/OpaqueData.cpp | 4 -- DDCore/src/Primitives.cpp | 4 -- DDCore/src/XML/DocumentHandler.cpp | 2 +- UtilityApps/CMakeLists.txt | 2 +- cmake/DD4hepBuild.cmake | 1 + 18 files changed, 81 insertions(+), 74 deletions(-) diff --git a/DDCore/include/DD4hep/Conditions.h b/DDCore/include/DD4hep/Conditions.h index 74d962fc5..8b40f75bd 100644 --- a/DDCore/include/DD4hep/Conditions.h +++ b/DDCore/include/DD4hep/Conditions.h @@ -210,6 +210,9 @@ namespace DD4hep { /// Constructor to be used when reading the already parsed object template <typename Q> Container(const Handle<Q>& e) : Handle<Object>(e) {} + /// Assignment operator + Container& operator=(const Container& c) = default; + /// Access the number of conditons keys available for this detector element size_t numKeys() const; @@ -278,7 +281,7 @@ namespace DD4hep { /// Automatic conversion to the string representation of the key object operator const std::string& () const { return name; } /// Automatic conversion to the hashed representation of the key object - operator key_type () const { return hash; } + operator key_type () const { return hash; } }; /// Hash code generation from input string diff --git a/DDCore/include/DD4hep/IOV.h b/DDCore/include/DD4hep/IOV.h index 7a91ec24e..7acca979c 100644 --- a/DDCore/include/DD4hep/IOV.h +++ b/DDCore/include/DD4hep/IOV.h @@ -33,11 +33,19 @@ namespace DD4hep { class IOVType { public: enum { UNKNOWN_IOV = ~0x0 } _IOVTypes; - + /// integer identifier ised internally unsigned int type; + /// String name std::string name; + /// Standard Constructor IOVType() : type(UNKNOWN_IOV), name() {} - ~IOVType() {} + /// Standard Destructor + ~IOVType() = default; + /// Copy constructor + IOVType(const IOVType& copy) : type(copy.type), name(copy.name) {} + /// Assignment operator + IOVType& operator=(const IOVType& copy); + /// Conversion to string std::string str() const; }; @@ -69,10 +77,9 @@ namespace DD4hep { /// Specialized copy constructor explicit IOV(const IOVType* typ, const Key& key); /// Copy constructor - IOV(const IOV& copy); - + IOV(const IOV& copy) = default; /// Standard Destructor - ~IOV(); + ~IOV() = default; /// Move the data content: 'from' will be reset to NULL void move(IOV& from); /// Create string representation of the IOV diff --git a/DDCore/include/DD4hep/LCDD.h b/DDCore/include/DD4hep/LCDD.h index 50cbeee8a..cd80feb2a 100644 --- a/DDCore/include/DD4hep/LCDD.h +++ b/DDCore/include/DD4hep/LCDD.h @@ -98,8 +98,7 @@ namespace DD4hep { typedef std::map<std::string, PropertyValues> Properties; /// Destructor - virtual ~LCDD() { - } + virtual ~LCDD() = default; /// Access flag to steer the detail of building of the geometry/detector description virtual LCDDBuildType buildType() const = 0; diff --git a/DDCore/include/DD4hep/LCDDData.h b/DDCore/include/DD4hep/LCDDData.h index e5336e778..2ec09ecd5 100644 --- a/DDCore/include/DD4hep/LCDDData.h +++ b/DDCore/include/DD4hep/LCDDData.h @@ -128,6 +128,10 @@ namespace DD4hep { LCDDData(); /// Default destructor virtual ~LCDDData(); + /// Copy constructor + LCDDData(const LCDDData& copy) = delete; + /// Assignment operator + //LCDDData& operator=(const LCDDData& copy) = delete; public: /// Clear data content: releases all allocated resources void destroyData(bool destroy_mgr=true); diff --git a/DDCore/include/DD4hep/ObjectExtensions.h b/DDCore/include/DD4hep/ObjectExtensions.h index 4936b8d53..25786beb9 100644 --- a/DDCore/include/DD4hep/ObjectExtensions.h +++ b/DDCore/include/DD4hep/ObjectExtensions.h @@ -60,8 +60,14 @@ namespace DD4hep { public: /// Default constructor ObjectExtensions(const std::type_info& parent_type); + /// Copy constructor + ObjectExtensions(const ObjectExtensions& copy) = delete; /// Default destructor virtual ~ObjectExtensions(); + /// Assignment operator + ObjectExtensions& operator=(const ObjectExtensions& copy) = delete; + /// Move extensions to target object + void move(ObjectExtensions& copy); /// Clear all extensions void clear(bool destroy=true); /// Copy object extensions from another object. Hosting type must be identical! diff --git a/DDCore/include/DD4hep/OpaqueData.h b/DDCore/include/DD4hep/OpaqueData.h index 980341dd6..2d573a022 100644 --- a/DDCore/include/DD4hep/OpaqueData.h +++ b/DDCore/include/DD4hep/OpaqueData.h @@ -39,11 +39,16 @@ namespace DD4hep { /// Standard initializing constructor OpaqueData(); /// Standard Destructor - virtual ~OpaqueData(); + virtual ~OpaqueData() = default; + /// Copy constructor + OpaqueData(const OpaqueData& copy) = default; + /// Assignment operator + OpaqueData& operator=(const OpaqueData& copy) = default; public: /// Data type const BasicGrammar* grammar; + protected: /// Pointer to object data void* pointer; diff --git a/DDCore/include/DD4hep/Primitives.h b/DDCore/include/DD4hep/Primitives.h index 169e2fe24..0aa675043 100644 --- a/DDCore/include/DD4hep/Primitives.h +++ b/DDCore/include/DD4hep/Primitives.h @@ -68,8 +68,10 @@ namespace DD4hep { invalid_handle_exception(const std::string& msg) : std::runtime_error(msg) {} /// Generic copy constructor invalid_handle_exception(const std::exception& e) : std::runtime_error(e.what()) {} + /// Generic copy constructor + invalid_handle_exception(const invalid_handle_exception& e) : std::runtime_error(e.what()) {} /// Default destructor of specialized exception - virtual ~invalid_handle_exception(); + virtual ~invalid_handle_exception() = default; }; /// ABI information about type names diff --git a/DDCore/src/Evaluator/stack.src b/DDCore/src/Evaluator/stack.src index 5a7831882..0da7e5531 100644 --- a/DDCore/src/Evaluator/stack.src +++ b/DDCore/src/Evaluator/stack.src @@ -22,8 +22,8 @@ private: int k, max_size; T * v; - stack(const stack& c) : k(0), max_size(0), v(0) {} - stack& operator=(const stack&) { k=0; max_size=0; v=0; return *this; } + stack(const stack& c) = delete; + stack& operator=(const stack&) = delete; public: stack() : k(0), max_size(20), v(new T[20]) {} diff --git a/DDCore/src/IOV.cpp b/DDCore/src/IOV.cpp index ae14a00e0..39e801d9a 100644 --- a/DDCore/src/IOV.cpp +++ b/DDCore/src/IOV.cpp @@ -23,6 +23,16 @@ using namespace std; using namespace DD4hep; +/// Assignment operator +IOVType& IOVType::operator=(const IOVType& copy) { + if ( © != this ) { + name = copy.name; + type = copy.type; + } + return *this; +} + +/// Conversion to string std::string IOVType::str() const { char text[256]; ::snprintf(text,sizeof(text),"%s(%d)",name.c_str(),int(type)); @@ -39,12 +49,6 @@ IOV::IOV(const IOVType* t) : iovType(t), keyData(0,0), optData(0) { type = t ? t->type : int(IOVType::UNKNOWN_IOV); } -/// Copy constructor -IOV::IOV(const IOV& c) - : iovType(c.iovType), keyData(c.keyData), optData(c.optData), type(c.type) -{ -} - /// Copy constructor IOV::IOV(const IOVType* t, const Key& k) : iovType(t), keyData(k), optData(0) @@ -52,10 +56,6 @@ IOV::IOV(const IOVType* t, const Key& k) type = t ? t->type : int(IOVType::UNKNOWN_IOV); } -/// Standard Destructor -IOV::~IOV() { -} - /// Set discrete IOV value void IOV::set(const Key& value) { keyData = value; diff --git a/DDCore/src/LCDDData.cpp b/DDCore/src/LCDDData.cpp index d7f048e1f..d728282d3 100644 --- a/DDCore/src/LCDDData.cpp +++ b/DDCore/src/LCDDData.cpp @@ -25,7 +25,6 @@ namespace DD4hep { namespace Geometry { class LCDDImp; }} using namespace DD4hep::Geometry; using namespace DD4hep; -using namespace std; /// Default constructor LCDDData::LCDDData() @@ -110,30 +109,28 @@ void LCDDData::clearData() { /// Adopt all data from source structure void LCDDData::adoptData(LCDDData& source) { m_inhibitConstants = source.m_inhibitConstants; - m_extensions = source.m_extensions; - m_motherVolumes = source.m_motherVolumes; - m_world = source.m_world; - m_field = source.m_field; - m_header = source.m_header; - m_properties = source.m_properties; - m_readouts = source.m_readouts; - m_idDict = source.m_idDict; - m_limits = source.m_limits; - m_regions = source.m_regions; - m_alignments = source.m_alignments; - m_sensitive = source.m_sensitive; - m_display = source.m_display; - m_fields = source.m_fields; - m_define = source.m_define; - m_trackers = source.m_trackers; - m_worldVol = source.m_worldVol; - m_trackingVol = source.m_trackingVol; - m_invisibleVis = source.m_invisibleVis; + m_extensions.move(source.m_extensions); + m_motherVolumes = source.m_motherVolumes; + m_world = source.m_world; + m_field = source.m_field; + m_header = source.m_header; + m_properties = source.m_properties; + m_readouts = source.m_readouts; + m_idDict = source.m_idDict; + m_limits = source.m_limits; + m_regions = source.m_regions; + m_alignments = source.m_alignments; + m_sensitive = source.m_sensitive; + m_display = source.m_display; + m_fields = source.m_fields; + m_define = source.m_define; + m_trackers = source.m_trackers; + m_worldVol = source.m_worldVol; + m_trackingVol = source.m_trackingVol; + m_invisibleVis = source.m_invisibleVis; m_materialVacuum = source.m_materialVacuum; - m_materialAir = source.m_materialAir; - m_manager = source.m_manager; - m_volManager = source.m_volManager; + m_materialAir = source.m_materialAir; + m_manager = source.m_manager; + m_volManager = source.m_volManager; source.clearData(); } - - diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp index f412ed579..6b169b4de 100644 --- a/DDCore/src/LCDDImp.cpp +++ b/DDCore/src/LCDDImp.cpp @@ -84,21 +84,6 @@ namespace { } } -/// Disable copy constructor -LCDDImp::LCDDImp(const LCDDImp& copy) : LCDD(copy), LCDDData(copy), LCDDLoad(this), - m_detectorTypes(copy.m_detectorTypes), - m_buildType(copy.m_buildType) -{ -} - -/// Disable assignment operator -LCDDImp& LCDDImp::operator=(const LCDDImp& c) { - // Useless, but keep code checker happy.... - m_detectorTypes = c.m_detectorTypes; - m_buildType = c.m_buildType; - return *this; -} - LCDD& LCDD::getInstance() { if (!s_lcdd) s_lcdd = new LCDDImp(); diff --git a/DDCore/src/LCDDImp.h b/DDCore/src/LCDDImp.h index 025b85669..ddd5cbb4c 100644 --- a/DDCore/src/LCDDImp.h +++ b/DDCore/src/LCDDImp.h @@ -50,10 +50,10 @@ namespace DD4hep { private: /// Disable copy constructor - LCDDImp(const LCDDImp& copy); + LCDDImp(const LCDDImp& copy) = delete; /// Disable assignment operator - LCDDImp& operator=(const LCDDImp& copy); + LCDDImp& operator=(const LCDDImp& copy) = delete; /// Internal helper to map detector types once the geometry is closed void mapDetectorTypes(); diff --git a/DDCore/src/ObjectExtensions.cpp b/DDCore/src/ObjectExtensions.cpp index c364b519e..182d8cefc 100644 --- a/DDCore/src/ObjectExtensions.cpp +++ b/DDCore/src/ObjectExtensions.cpp @@ -42,6 +42,12 @@ ObjectExtensions::~ObjectExtensions() { InstanceCount::decrement(this); } +/// Move extensions to target object +void ObjectExtensions::move(ObjectExtensions& source) { + extensions = source.extensions; + source.extensions.clear(); +} + /// Internal object destructor: release extension object(s) void ObjectExtensions::clear(bool destroy) { for (Extensions::iterator i = extensions.begin(); i != extensions.end(); ++i) { diff --git a/DDCore/src/OpaqueData.cpp b/DDCore/src/OpaqueData.cpp index 76dce8536..94ccf8b65 100644 --- a/DDCore/src/OpaqueData.cpp +++ b/DDCore/src/OpaqueData.cpp @@ -29,10 +29,6 @@ using namespace DD4hep; OpaqueData::OpaqueData() : grammar(0), pointer(0) { } -/// Standard Destructor -OpaqueData::~OpaqueData() { -} - /// Create data block from string representation bool OpaqueData::fromString(const string& rep) { if ( pointer && grammar ) { diff --git a/DDCore/src/Primitives.cpp b/DDCore/src/Primitives.cpp index b50c25688..e61ed5372 100644 --- a/DDCore/src/Primitives.cpp +++ b/DDCore/src/Primitives.cpp @@ -188,10 +188,6 @@ std::string DD4hep::typeName(const std::type_info& typ) { return __typeinfoName(typ); } -/// Default destructor of specialized exception -DD4hep::invalid_handle_exception::~invalid_handle_exception() { -} - void DD4hep::invalidHandleError(const std::type_info& type) { throw invalid_handle_exception("Attempt to access invalid object of type "+typeName(type)+" [Invalid Handle]"); diff --git a/DDCore/src/XML/DocumentHandler.cpp b/DDCore/src/XML/DocumentHandler.cpp index 901b7d308..43d7edfe2 100644 --- a/DDCore/src/XML/DocumentHandler.cpp +++ b/DDCore/src/XML/DocumentHandler.cpp @@ -377,7 +377,7 @@ namespace DD4hep { namespace XML { /// XML-DOM ERror handler class for the TinyXML document parser (Compatibility class) - struct DocumentErrorHandler {}; + class DocumentErrorHandler {}; union Xml { Xml(void* ptr) : p(ptr) {} diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index 242e7e959..2876c182b 100644 --- a/UtilityApps/CMakeLists.txt +++ b/UtilityApps/CMakeLists.txt @@ -10,7 +10,7 @@ # #========================================================================== dd4hep_package(UtilityApps - USES DDCore + USES DDSegmentation DDCore [ROOT REQUIRED COMPONENTS Geom] ) #----------------------------------------------------------------------------------- diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index ef3a98c8c..52f4919ad 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -39,6 +39,7 @@ macro(dd4hep_set_compiler_flags) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") endif() -- GitLab