Skip to content

Commit

Permalink
Merge branch 'lm_warnings': Fixes lots of Clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmatena committed Feb 8, 2021
2 parents cd1322c + a772863 commit 8fbafbe
Show file tree
Hide file tree
Showing 63 changed files with 192 additions and 224 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ if (NOT MSVC AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMP
add_compile_options(-Wno-ignored-attributes) # Tamas: Eigen include dirs are marked as SYSTEM
endif()

# Clang reports legacy OpenGL calls as deprecated. Turn off the warning for now
# to reduce the clutter, we know about this one. It should be reenabled after
# we finally get rid of the deprecated code.
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_compile_options(-Wno-deprecated-declarations)
endif()

#GCC generates loads of -Wunknown-pragmas when compiling igl. The fix is not easy due to a bug in gcc, see
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66943 or
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/AABBTreeIndirect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ inline bool intersect_ray_all_hits(
std::vector<igl::Hit> &hits)
{
auto ray_intersector = detail::RayIntersectorHits<VertexType, IndexedFaceType, TreeType, VectorType> {
vertices, faces, tree,
vertices, faces, {tree},
origin, dir, VectorType(dir.cwiseInverse())
};
if (! tree.empty()) {
Expand Down
8 changes: 4 additions & 4 deletions src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ void AppConfig::save()
else
c << "# " << Slic3r::header_gcodeviewer_generated() << std::endl;
// Make sure the "no" category is written first.
for (const std::pair<std::string, std::string> &kvp : m_storage[""])
for (const auto& kvp : m_storage[""])
c << kvp.first << " = " << kvp.second << std::endl;
// Write the other categories.
for (const auto category : m_storage) {
for (const auto& category : m_storage) {
if (category.first.empty())
continue;
c << std::endl << "[" << category.first << "]" << std::endl;
for (const std::pair<std::string, std::string> &kvp : category.second)
for (const auto& kvp : category.second)
c << kvp.first << " = " << kvp.second << std::endl;
}
// Write vendor sections
Expand Down Expand Up @@ -395,7 +395,7 @@ std::vector<std::string> AppConfig::get_mouse_device_names() const
static constexpr const char *prefix = "mouse_device:";
static const size_t prefix_len = strlen(prefix);
std::vector<std::string> out;
for (const std::pair<std::string, std::map<std::string, std::string>>& key_value_pair : m_storage)
for (const auto& key_value_pair : m_storage)
if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len)
out.emplace_back(key_value_pair.first.substr(prefix_len));
return out;
Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ class ConfigOptionEnum : public ConfigOptionSingle<T>

static bool has(T value)
{
for (const std::pair<std::string, int> &kvp : ConfigOptionEnum<T>::get_enum_values())
for (const auto &kvp : ConfigOptionEnum<T>::get_enum_values())
if (kvp.second == value)
return true;
return false;
Expand All @@ -1358,11 +1358,11 @@ class ConfigOptionEnum : public ConfigOptionSingle<T>
// Initialize the map.
const t_config_enum_values &enum_keys_map = ConfigOptionEnum<T>::get_enum_values();
int cnt = 0;
for (const std::pair<std::string, int> &kvp : enum_keys_map)
for (const auto& kvp : enum_keys_map)
cnt = std::max(cnt, kvp.second);
cnt += 1;
names.assign(cnt, "");
for (const std::pair<std::string, int> &kvp : enum_keys_map)
for (const auto& kvp : enum_keys_map)
names[kvp.second] = kvp.first;
}
return names;
Expand Down
18 changes: 9 additions & 9 deletions src/libslic3r/Fill/FillRectilinear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Surface;
class FillRectilinear : public Fill
{
public:
Fill* clone() const override { return new FillRectilinear(*this); };
Fill* clone() const override { return new FillRectilinear(*this); }
~FillRectilinear() override = default;
Polylines fill_surface(const Surface *surface, const FillParams &params) override;

Expand All @@ -32,18 +32,18 @@ class FillRectilinear : public Fill
class FillAlignedRectilinear : public FillRectilinear
{
public:
Fill* clone() const override { return new FillAlignedRectilinear(*this); };
Fill* clone() const override { return new FillAlignedRectilinear(*this); }
~FillAlignedRectilinear() override = default;

protected:
// Always generate infill at the same angle.
virtual float _layer_angle(size_t idx) const { return 0.f; }
virtual float _layer_angle(size_t idx) const override { return 0.f; }
};

class FillMonotonic : public FillRectilinear
{
public:
Fill* clone() const override { return new FillMonotonic(*this); };
Fill* clone() const override { return new FillMonotonic(*this); }
~FillMonotonic() override = default;
Polylines fill_surface(const Surface *surface, const FillParams &params) override;
bool no_sort() const override { return true; }
Expand All @@ -52,7 +52,7 @@ class FillMonotonic : public FillRectilinear
class FillGrid : public FillRectilinear
{
public:
Fill* clone() const override { return new FillGrid(*this); };
Fill* clone() const override { return new FillGrid(*this); }
~FillGrid() override = default;
Polylines fill_surface(const Surface *surface, const FillParams &params) override;

Expand All @@ -64,7 +64,7 @@ class FillGrid : public FillRectilinear
class FillTriangles : public FillRectilinear
{
public:
Fill* clone() const override { return new FillTriangles(*this); };
Fill* clone() const override { return new FillTriangles(*this); }
~FillTriangles() override = default;
Polylines fill_surface(const Surface *surface, const FillParams &params) override;

Expand All @@ -76,7 +76,7 @@ class FillTriangles : public FillRectilinear
class FillStars : public FillRectilinear
{
public:
Fill* clone() const override { return new FillStars(*this); };
Fill* clone() const override { return new FillStars(*this); }
~FillStars() override = default;
Polylines fill_surface(const Surface *surface, const FillParams &params) override;

Expand All @@ -88,7 +88,7 @@ class FillStars : public FillRectilinear
class FillCubic : public FillRectilinear
{
public:
Fill* clone() const override { return new FillCubic(*this); };
Fill* clone() const override { return new FillCubic(*this); }
~FillCubic() override = default;
Polylines fill_surface(const Surface *surface, const FillParams &params) override;

Expand All @@ -98,6 +98,6 @@ class FillCubic : public FillRectilinear
};


}; // namespace Slic3r
} // namespace Slic3r

#endif // slic3r_FillRectilinear_hpp_
1 change: 0 additions & 1 deletion src/libslic3r/Format/3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const char* VALID_OBJECT_TYPES[] =
"model"
};

const unsigned int INVALID_OBJECT_TYPES_COUNT = 4;
const char* INVALID_OBJECT_TYPES[] =
{
"solidsupport",
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ namespace DoExport {
double extruded_volume = extruder.extruded_volume() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] * 2.4052f : 0.f); // assumes 1.75mm filament diameter
double filament_weight = extruded_volume * extruder.filament_density() * 0.001;
double filament_cost = filament_weight * extruder.filament_cost() * 0.001;
auto append = [&extruder, &extruders](std::pair<std::string, unsigned int> &dst, const char *tmpl, double value) {
auto append = [&extruder](std::pair<std::string, unsigned int> &dst, const char *tmpl, double value) {
while (dst.second < extruder.id()) {
// Fill in the non-printing extruders with zeros.
dst.first += (dst.second > 0) ? ", 0" : "0";
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode/SeamPlacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ static std::vector<size_t> find_enforcer_centers(const Polygon& polygon,
if (polygon.size() < 2 || enforcers_idxs.empty())
return out;

auto get_center_idx = [&polygon, &lengths](size_t start_idx, size_t end_idx) -> size_t {
auto get_center_idx = [&lengths](size_t start_idx, size_t end_idx) -> size_t {
assert(end_idx >= start_idx);
if (start_idx == end_idx)
return start_idx;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode/WipeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class WipeTowerWriter

WipeTowerWriter& append(const std::string& text) { m_gcode += text; return *this; }

std::vector<Vec2f> wipe_path() const
const std::vector<Vec2f>& wipe_path() const
{
return m_wipe_path;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ inline bool liang_barsky_line_clipping_interval(
double t0 = 0.0;
double t1 = 1.0;
// Traverse through left, right, bottom, top edges.
auto clip_side = [&x0, &v, &bbox, &t0, &t1](double p, double q) -> bool {
auto clip_side = [&t0, &t1](double p, double q) -> bool {
if (p == 0) {
if (q < 0)
// Line parallel to the bounding box edge is fully outside of the bounding box.
Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/LayerRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
surfaces_append(bottom, union_ex(grown, true), bridges[idx_last]);
}

fill_boundaries = std::move(to_polygons(fill_boundaries_ex));
fill_boundaries = to_polygons(fill_boundaries_ex);
BOOST_LOG_TRIVIAL(trace) << "Processing external surface, detecting bridges - done";
}

Expand Down Expand Up @@ -327,7 +327,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
surfaces_append(
new_surfaces,
// Don't use a safety offset as fill_boundaries were already united using the safety offset.
std::move(intersection_ex(polys, fill_boundaries, false)),
intersection_ex(polys, fill_boundaries, false),
s1);
}
}
Expand Down Expand Up @@ -424,7 +424,7 @@ void LayerRegion::elephant_foot_compensation_step(const float elephant_foot_comp
Polygons slices_polygons = to_polygons(slices_expolygons);
Polygons tmp = intersection(slices_polygons, trimming_polygons, false);
append(tmp, diff(slices_polygons, offset(offset_ex(slices_expolygons, -elephant_foot_compensation_perimeter_step), elephant_foot_compensation_perimeter_step)));
this->slices.set(std::move(union_ex(tmp)), stInternal);
this->slices.set(union_ex(tmp), stInternal);
}

void LayerRegion::export_region_slices_to_svg(const char *path) const
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/MarchingSquares.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ template<class Rst> class Grid {
case SquareTag::full:
case SquareTag::none: {
Coord crd{tl(cell) + Coord{m_cellsize.r / 2, m_cellsize.c / 2}};
return {{crd, Dir::none, m_rst}, crd};
return {{crd, Dir::none, m_rst}, {crd}};
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PresetBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
std::string bundle_name = std::string(" - ") + boost::filesystem::path(path).filename().string();

// 2) Extract active configs from the config bundle, copy them and activate them in this bundle.
auto load_one = [this, &path, &bundle_name](PresetCollection &collection_dst, PresetCollection &collection_src, const std::string &preset_name_src, bool activate) -> std::string {
auto load_one = [&path, &bundle_name](PresetCollection &collection_dst, PresetCollection &collection_src, const std::string &preset_name_src, bool activate) -> std::string {
Preset *preset_src = collection_src.find_preset(preset_name_src, false);
Preset *preset_dst = collection_dst.find_preset(preset_name_src, false);
assert(preset_src != nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ std::string Print::validate() const
return L("One or more object were assigned an extruder that the printer does not have.");
#endif

auto validate_extrusion_width = [min_nozzle_diameter, max_nozzle_diameter](const ConfigBase &config, const char *opt_key, double layer_height, std::string &err_msg) -> bool {
auto validate_extrusion_width = [/*min_nozzle_diameter,*/ max_nozzle_diameter](const ConfigBase &config, const char *opt_key, double layer_height, std::string &err_msg) -> bool {
// This may change in the future, if we switch to "extrusion width wrt. nozzle diameter"
// instead of currently used logic "extrusion width wrt. layer height", see GH issues #1923 #2829.
// double extrusion_width_min = config.get_abs_value(opt_key, min_nozzle_diameter);
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ void PrintObject::detect_surfaces_type()
// Fill in layerm->fill_surfaces by trimming the layerm->slices by the cummulative layerm->fill_surfaces.
tbb::parallel_for(
tbb::blocked_range<size_t>(0, m_layers.size()),
[this, idx_region, interface_shells](const tbb::blocked_range<size_t>& range) {
[this, idx_region](const tbb::blocked_range<size_t>& range) {
for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) {
m_print->throw_if_canceled();
LayerRegion *layerm = m_layers[idx_layer]->m_regions[idx_region];
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/SLA/Concurrency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ template<> struct _ccr<true>
static void for_each(It from, It to, Fn &&fn, size_t granularity = 1)
{
tbb::parallel_for(tbb::blocked_range{from, to, granularity},
[&fn, from](const auto &range) {
[&fn](const auto &range) {
loop_(range, std::forward<Fn>(fn));
});
}
Expand Down
2 changes: 0 additions & 2 deletions src/libslic3r/SLA/IndexedMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class IndexedMesh::AABBImpl {
}
};

static const constexpr double MESH_EPS = 1e-6;

IndexedMesh::IndexedMesh(const TriangleMesh& tmesh)
: m_aabb(new AABBImpl()), m_tm(&tmesh)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/SLA/Rotfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ XYRotation from_transform3d(const Transform3d &tr)
template<size_t N, class Fn, class It, class StopCond>
std::array<double, N> find_min_score(Fn &&fn, It from, It to, StopCond &&stopfn)
{
std::array<double, N> ret;
std::array<double, N> ret = {};

double score = std::numeric_limits<double>::max();

Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/SLAPrint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class SLAPrint : public PrintBaseWithState<SLAPrintStep, slapsCount>
void clear() override;
bool empty() const override { return m_objects.empty(); }
// List of existing PrintObject IDs, to remove notifications for non-existent IDs.
std::vector<ObjectID> print_object_ids() const;
std::vector<ObjectID> print_object_ids() const override;
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
void set_task(const TaskParams &params) override;
void process() override;
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/ShortestPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ static inline void do_crossover(const std::vector<FlipEdge> &edges_in, std::vect
const std::pair<size_t, size_t> &span2, bool reversed2, bool flipped2,
const std::pair<size_t, size_t> &span3, bool reversed3, bool flipped3) {
auto it_edges_out = edges_out.begin();
auto copy_span = [&edges_in, &edges_out, &it_edges_out](std::pair<size_t, size_t> span, bool reversed, bool flipped) {
auto copy_span = [&edges_in, &it_edges_out](std::pair<size_t, size_t> span, bool reversed, bool flipped) {
assert(span.first < span.second);
auto it = it_edges_out;
if (reversed)
Expand Down Expand Up @@ -1466,7 +1466,7 @@ static inline void do_crossover(const std::vector<FlipEdge> &edges_in, std::vect
const std::pair<size_t, size_t> &span3, bool reversed3, bool flipped3,
const std::pair<size_t, size_t> &span4, bool reversed4, bool flipped4) {
auto it_edges_out = edges_out.begin();
auto copy_span = [&edges_in, &edges_out, &it_edges_out](std::pair<size_t, size_t> span, bool reversed, bool flipped) {
auto copy_span = [&edges_in, &it_edges_out](std::pair<size_t, size_t> span, bool reversed, bool flipped) {
assert(span.first < span.second);
auto it = it_edges_out;
if (reversed)
Expand Down
32 changes: 3 additions & 29 deletions src/libslic3r/SupportMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::bottom_conta
});

Polygons &layer_support_area = layer_support_areas[layer_id];
task_group.run([this, &projection, &projection_raw, &layer, &layer_support_area, layer_id] {
task_group.run([this, &projection, &projection_raw, &layer, &layer_support_area] {
// Remove the areas that touched from the projection that will continue on next, lower, top surfaces.
// Polygons trimming = union_(to_polygons(layer.slices), touching, true);
Polygons trimming = offset(layer.lslices, float(SCALED_EPSILON));
Expand Down Expand Up @@ -1736,7 +1736,7 @@ void PrintObjectSupportMaterial::trim_top_contacts_by_bottom_contacts(
const PrintObject &object, const MyLayersPtr &bottom_contacts, MyLayersPtr &top_contacts) const
{
tbb::parallel_for(tbb::blocked_range<int>(0, int(top_contacts.size())),
[this, &object, &bottom_contacts, &top_contacts](const tbb::blocked_range<int>& range) {
[&bottom_contacts, &top_contacts](const tbb::blocked_range<int>& range) {
int idx_bottom_overlapping_first = -2;
// For all top contact layers, counting downwards due to the way idx_higher_or_equal caches the last index to avoid repeated binary search.
for (int idx_top = range.end() - 1; idx_top >= range.begin(); -- idx_top) {
Expand Down Expand Up @@ -1965,7 +1965,7 @@ void PrintObjectSupportMaterial::generate_base_layers(
BOOST_LOG_TRIVIAL(debug) << "PrintObjectSupportMaterial::generate_base_layers() in parallel - start";
tbb::parallel_for(
tbb::blocked_range<size_t>(0, intermediate_layers.size()),
[this, &object, &bottom_contacts, &top_contacts, &intermediate_layers, &layer_support_areas](const tbb::blocked_range<size_t>& range) {
[&object, &bottom_contacts, &top_contacts, &intermediate_layers, &layer_support_areas](const tbb::blocked_range<size_t>& range) {
// index -2 means not initialized yet, -1 means intialized and decremented to 0 and then -1.
int idx_top_contact_above = -2;
int idx_bottom_contact_overlapping = -2;
Expand Down Expand Up @@ -2328,32 +2328,6 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_int
return interface_layers;
}

static inline void fill_expolygons_generate_paths(
ExtrusionEntitiesPtr &dst,
const ExPolygons &expolygons,
Fill *filler,
float density,
ExtrusionRole role,
const Flow &flow)
{
FillParams fill_params;
fill_params.density = density;
fill_params.dont_adjust = true;
for (const ExPolygon &expoly : expolygons) {
Surface surface(stInternal, expoly);
Polylines polylines;
try {
polylines = filler->fill_surface(&surface, fill_params);
} catch (InfillFailedException &) {
}
extrusion_entities_append_paths(
dst,
std::move(polylines),
role,
flow.mm3_per_mm(), flow.width, flow.height);
}
}

static inline void fill_expolygons_generate_paths(
ExtrusionEntitiesPtr &dst,
ExPolygons &&expolygons,
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/SupportMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class PrintObjectSupportMaterial
bool m_can_merge_support_regions;

coordf_t m_support_layer_height_min;
coordf_t m_support_layer_height_max;
// coordf_t m_support_layer_height_max;

coordf_t m_gap_xy;
};
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/TriangleMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enum FacetEdgeType {
class IntersectionReference
{
public:
IntersectionReference() : point_id(-1), edge_id(-1) {};
IntersectionReference() : point_id(-1), edge_id(-1) {}
IntersectionReference(int point_id, int edge_id) : point_id(point_id), edge_id(edge_id) {}
// Where is this intersection point located? On mesh vertex or mesh edge?
// Only one of the following will be set, the other will remain set to -1.
Expand All @@ -116,7 +116,7 @@ class IntersectionReference
class IntersectionPoint : public Point, public IntersectionReference
{
public:
IntersectionPoint() {};
IntersectionPoint() {}
IntersectionPoint(int point_id, int edge_id, const Point &pt) : IntersectionReference(point_id, edge_id), Point(pt) {}
IntersectionPoint(const IntersectionReference &ir, const Point &pt) : IntersectionReference(ir), Point(pt) {}
// Inherits coord_t x, y
Expand Down
Loading

0 comments on commit 8fbafbe

Please sign in to comment.