Skip to content

Commit e8b28a0

Browse files
committed
Some fixes for clang
1 parent 9a30397 commit e8b28a0

8 files changed

Lines changed: 30 additions & 16 deletions

File tree

src/ifcgeom/IfcGeom.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ class IFC_GEOM_API MAKE_TYPE_NAME(Kernel) : public IfcGeom::Kernel {
333333
return items;
334334
}
335335

336+
virtual bool convert_placement(IfcUtil::IfcBaseClass* item, gp_Trsf& trsf) {
337+
if (item->as<IfcSchema::IfcObjectPlacement>()) {
338+
return convert(item->as<IfcSchema::IfcObjectPlacement>(), trsf);
339+
} else {
340+
return false;
341+
}
342+
}
343+
336344
};
337345

338346
IfcUtil::IfcBaseClass* MAKE_TYPE_NAME(tesselate_)(const TopoDS_Shape& shape, double deflection);

src/ifcgeom/IfcGeomIteratorImplementation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ namespace IfcGeom {
607607
ifc_product = ifc_entity->as<IfcSchema::IfcProduct>();
608608
parent_id = -1;
609609
try {
610-
IfcSchema::IfcObjectDefinition* parent_object = kernel.get_decomposing_entity(ifc_product)->as<IfcSchema::IfcObjectDefinition>();
610+
IfcSchema::IfcObjectDefinition* parent_object = kernel.get_decomposing_entity(ifc_product)->template as<IfcSchema::IfcObjectDefinition>();
611611
if (parent_object) {
612612
parent_id = parent_object->data().id();
613613
}

src/ifcgeom_schema_agnostic/Kernel.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBase
128128
}
129129

130130
namespace {
131+
132+
// LayerAssignments renamed from plural to singular, LayerAssignment, so work around that
133+
IfcEntityList::ptr getLayerAssignments(Ifc2x3::IfcRepresentationItem* item) {
134+
return item->LayerAssignments()->generalize();
135+
}
136+
IfcEntityList::ptr getLayerAssignments(Ifc4::IfcRepresentationItem* item) {
137+
return item->LayerAssignment()->generalize();
138+
}
139+
131140
template <typename Schema>
132141
static std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers_impl(typename Schema::IfcProduct* prod) {
133142
std::map<std::string, IfcUtil::IfcBaseEntity*> layers;

src/ifcgeom_schema_agnostic/Kernel.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@
1212

1313
#include <TopExp_Explorer.hxx>
1414

15-
namespace {
16-
// LayerAssignments renamed from plural to singular, LayerAssignment, so work around that
17-
IfcEntityList::ptr getLayerAssignments(Ifc2x3::IfcRepresentationItem* item) {
18-
return item->LayerAssignments()->generalize();
19-
}
20-
IfcEntityList::ptr getLayerAssignments(Ifc4::IfcRepresentationItem* item) {
21-
return item->LayerAssignment()->generalize();
22-
}
23-
}
24-
2515
namespace IfcGeom {
2616

2717
template <typename P, typename PP>
@@ -89,8 +79,8 @@ namespace IfcGeom {
8979
return implementation_->convert(item);
9080
}
9181

92-
virtual bool convert(IfcUtil::IfcBaseClass* item, gp_Trsf& trsf) {
93-
return implementation_->convert(item, trsf);
82+
virtual bool convert_placement(IfcUtil::IfcBaseClass* item, gp_Trsf& trsf) {
83+
return implementation_->convert_placement(item, trsf);
9484
}
9585

9686
static int count(const TopoDS_Shape&, TopAbs_ShapeEnum);

src/ifcparse/Ifc2x3-schema.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,7 @@ class IFC2X3_instance_factory : public IfcParse::instance_factory {
17911791

17921792

17931793
#if defined(__clang__)
1794+
__attribute__((optnone))
17941795
#elif defined(__GNUC__) || defined(__GNUG__)
17951796
#pragma GCC push_options
17961797
#pragma GCC optimize ("O0")

src/ifcparse/Ifc4-schema.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,7 @@ class IFC4_instance_factory : public IfcParse::instance_factory {
21052105

21062106

21072107
#if defined(__clang__)
2108+
__attribute__((optnone))
21082109
#elif defined(__GNUC__) || defined(__GNUG__)
21092110
#pragma GCC push_options
21102111
#pragma GCC optimize ("O0")

src/ifcparse/IfcBaseClass.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ namespace IfcUtil {
3838
class IFC_PARSE_API IfcBaseClass {
3939
protected:
4040
IfcEntityInstanceData* data_;
41+
42+
static bool is_null(const IfcBaseClass* not_this) {
43+
return !not_this;
44+
}
4145

4246
public:
4347
IfcBaseClass() : data_(0) {}
@@ -52,7 +56,8 @@ namespace IfcUtil {
5256

5357
template <class T>
5458
T* as() {
55-
if (this == 0) {
59+
// @todo: do not allow this to be null in the first place
60+
if (is_null(this)) {
5661
return static_cast<T*>(0);
5762
}
5863
return declaration().is(T::Class())
@@ -62,7 +67,7 @@ namespace IfcUtil {
6267

6368
template <class T>
6469
const T* as() const {
65-
if (this == 0) {
70+
if (is_null(this)) {
6671
return static_cast<const T*>(0);
6772
}
6873
return declaration().is(T::Class())

src/ifcparse/parse_ifcxml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
527527
instance_to_attribute(inst_or_reference, attr, newinst);
528528
state->stack.back().inst()->data().setArgument(idx, attr);
529529
state->stack.push_back(stack_node::instance(id_in_file, newinst));
530-
} else if (auto select = attribute_type->as_named_type()->declared_type()->as_select_type()) {
530+
} else if (attribute_type->as_named_type()->declared_type()->as_select_type()) {
531531
// Select types cause an additional indirection, so the current stack node is simply repeated
532532
state->stack.push_back(stack_node::select(state->stack.back().inst(), idx));
533533
}

0 commit comments

Comments
 (0)