From e8b28a099f13c1ab9a4f2bff84d7e4c11496cba8 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 19 Sep 2018 14:05:19 +0200 Subject: [PATCH] Some fixes for clang --- src/ifcgeom/IfcGeom.h | 8 ++++++++ src/ifcgeom/IfcGeomIteratorImplementation.h | 2 +- src/ifcgeom_schema_agnostic/Kernel.cpp | 9 +++++++++ src/ifcgeom_schema_agnostic/Kernel.h | 14 ++------------ src/ifcparse/Ifc2x3-schema.cpp | 1 + src/ifcparse/Ifc4-schema.cpp | 1 + src/ifcparse/IfcBaseClass.h | 9 +++++++-- src/ifcparse/parse_ifcxml.cpp | 2 +- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index 242240bb53..0d4d435247 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -333,6 +333,14 @@ public: return items; } + virtual bool convert_placement(IfcUtil::IfcBaseClass* item, gp_Trsf& trsf) { + if (item->as()) { + return convert(item->as(), trsf); + } else { + return false; + } + } + }; IfcUtil::IfcBaseClass* MAKE_TYPE_NAME(tesselate_)(const TopoDS_Shape& shape, double deflection); diff --git a/src/ifcgeom/IfcGeomIteratorImplementation.h b/src/ifcgeom/IfcGeomIteratorImplementation.h index 1dc85b122e..b1bf97a544 100644 --- a/src/ifcgeom/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/IfcGeomIteratorImplementation.h @@ -607,7 +607,7 @@ namespace IfcGeom { ifc_product = ifc_entity->as(); parent_id = -1; try { - IfcSchema::IfcObjectDefinition* parent_object = kernel.get_decomposing_entity(ifc_product)->as(); + IfcSchema::IfcObjectDefinition* parent_object = kernel.get_decomposing_entity(ifc_product)->template as(); if (parent_object) { parent_id = parent_object->data().id(); } diff --git a/src/ifcgeom_schema_agnostic/Kernel.cpp b/src/ifcgeom_schema_agnostic/Kernel.cpp index d4f154fae9..cb6d1d983f 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.cpp +++ b/src/ifcgeom_schema_agnostic/Kernel.cpp @@ -128,6 +128,15 @@ IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBase } namespace { + + // LayerAssignments renamed from plural to singular, LayerAssignment, so work around that + IfcEntityList::ptr getLayerAssignments(Ifc2x3::IfcRepresentationItem* item) { + return item->LayerAssignments()->generalize(); + } + IfcEntityList::ptr getLayerAssignments(Ifc4::IfcRepresentationItem* item) { + return item->LayerAssignment()->generalize(); + } + template static std::map get_layers_impl(typename Schema::IfcProduct* prod) { std::map layers; diff --git a/src/ifcgeom_schema_agnostic/Kernel.h b/src/ifcgeom_schema_agnostic/Kernel.h index 01ef45cb06..df3a39a14f 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.h +++ b/src/ifcgeom_schema_agnostic/Kernel.h @@ -12,16 +12,6 @@ #include -namespace { - // LayerAssignments renamed from plural to singular, LayerAssignment, so work around that - IfcEntityList::ptr getLayerAssignments(Ifc2x3::IfcRepresentationItem* item) { - return item->LayerAssignments()->generalize(); - } - IfcEntityList::ptr getLayerAssignments(Ifc4::IfcRepresentationItem* item) { - return item->LayerAssignment()->generalize(); - } -} - namespace IfcGeom { template @@ -89,8 +79,8 @@ namespace IfcGeom { return implementation_->convert(item); } - virtual bool convert(IfcUtil::IfcBaseClass* item, gp_Trsf& trsf) { - return implementation_->convert(item, trsf); + virtual bool convert_placement(IfcUtil::IfcBaseClass* item, gp_Trsf& trsf) { + return implementation_->convert_placement(item, trsf); } static int count(const TopoDS_Shape&, TopAbs_ShapeEnum); diff --git a/src/ifcparse/Ifc2x3-schema.cpp b/src/ifcparse/Ifc2x3-schema.cpp index b2efe781c1..845c869bf2 100644 --- a/src/ifcparse/Ifc2x3-schema.cpp +++ b/src/ifcparse/Ifc2x3-schema.cpp @@ -1791,6 +1791,7 @@ class IFC2X3_instance_factory : public IfcParse::instance_factory { #if defined(__clang__) +__attribute__((optnone)) #elif defined(__GNUC__) || defined(__GNUG__) #pragma GCC push_options #pragma GCC optimize ("O0") diff --git a/src/ifcparse/Ifc4-schema.cpp b/src/ifcparse/Ifc4-schema.cpp index b225281ef5..5b5644b777 100644 --- a/src/ifcparse/Ifc4-schema.cpp +++ b/src/ifcparse/Ifc4-schema.cpp @@ -2105,6 +2105,7 @@ class IFC4_instance_factory : public IfcParse::instance_factory { #if defined(__clang__) +__attribute__((optnone)) #elif defined(__GNUC__) || defined(__GNUG__) #pragma GCC push_options #pragma GCC optimize ("O0") diff --git a/src/ifcparse/IfcBaseClass.h b/src/ifcparse/IfcBaseClass.h index d0518e62b1..ee53fdca93 100644 --- a/src/ifcparse/IfcBaseClass.h +++ b/src/ifcparse/IfcBaseClass.h @@ -38,6 +38,10 @@ namespace IfcUtil { class IFC_PARSE_API IfcBaseClass { protected: IfcEntityInstanceData* data_; + + static bool is_null(const IfcBaseClass* not_this) { + return !not_this; + } public: IfcBaseClass() : data_(0) {} @@ -52,7 +56,8 @@ namespace IfcUtil { template T* as() { - if (this == 0) { + // @todo: do not allow this to be null in the first place + if (is_null(this)) { return static_cast(0); } return declaration().is(T::Class()) @@ -62,7 +67,7 @@ namespace IfcUtil { template const T* as() const { - if (this == 0) { + if (is_null(this)) { return static_cast(0); } return declaration().is(T::Class()) diff --git a/src/ifcparse/parse_ifcxml.cpp b/src/ifcparse/parse_ifcxml.cpp index 0cada44589..b211c7cbcc 100644 --- a/src/ifcparse/parse_ifcxml.cpp +++ b/src/ifcparse/parse_ifcxml.cpp @@ -527,7 +527,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs) instance_to_attribute(inst_or_reference, attr, newinst); state->stack.back().inst()->data().setArgument(idx, attr); state->stack.push_back(stack_node::instance(id_in_file, newinst)); - } else if (auto select = attribute_type->as_named_type()->declared_type()->as_select_type()) { + } else if (attribute_type->as_named_type()->declared_type()->as_select_type()) { // Select types cause an additional indirection, so the current stack node is simply repeated state->stack.push_back(stack_node::select(state->stack.back().inst(), idx)); }