Skip to content

Commit 457b8a1

Browse files
authored
Additional Compiler Warnings (#73)
1 parent 5370866 commit 457b8a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+571
-500
lines changed

cmake/ipc_toolkit/ipc_toolkit_warnings.cmake

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@ endif()
1010
set(IPC_TOOLKIT_WARNING_FLAGS
1111
-Wall
1212
-Wextra
13-
-pedantic
13+
-Wpedantic
14+
# -Werror
1415

1516
# -Wconversion
17+
# -Wsign-conversion
1618
# -Wunsafe-loop-optimizations # broken with C++11 loops
1719
-Wunused
1820

19-
-Wno-long-long
21+
-Wno-long-long # disable warnings about using long long
2022
-Wpointer-arith
2123
-Wformat=2
2224
-Wuninitialized
2325
-Wcast-qual
24-
# -Wmissing-noreturn
26+
-Wmissing-noreturn
2527
-Wmissing-format-attribute
26-
# -Wredundant-decls
28+
-Wredundant-decls
2729

2830
-Werror=implicit
2931
-Werror=nonnull
@@ -43,11 +45,10 @@ set(IPC_TOOLKIT_WARNING_FLAGS
4345
-Wunused-but-set-variable
4446
-Wno-unused-parameter
4547

46-
#-Weffc++
48+
# -Weffc++
4749
-Wold-style-cast
48-
# -Wsign-conversion
4950

50-
# -Wshadow
51+
-Wshadow
5152

5253
-Wstrict-null-sentinel
5354
-Woverloaded-virtual
@@ -60,7 +61,7 @@ set(IPC_TOOLKIT_WARNING_FLAGS
6061
# lacks a case for one or more of the named codes of that enumeration.
6162
-Wswitch
6263
# This is annoying if all cases are already covered.
63-
# -Wswitch-default
64+
-Wswitch-default
6465
# This is annoying if there is a default that covers the rest.
6566
# -Wswitch-enum
6667
-Wswitch-unreachable
@@ -70,20 +71,17 @@ set(IPC_TOOLKIT_WARNING_FLAGS
7071
-Wdisabled-optimization
7172
# -Winline # produces warning on default implicit destructor
7273
-Winvalid-pch
73-
# -Wmissing-include-dirs
74+
-Wmissing-include-dirs
7475
-Wpacked
7576
-Wno-padded
7677
-Wstrict-overflow
7778
-Wstrict-overflow=2
7879

79-
# -Wctor-dtor-privacy
80+
-Wctor-dtor-privacy
8081
-Wlogical-op
81-
# -Wnoexcept
8282
-Woverloaded-virtual
8383
# -Wundef
8484

85-
-Wnon-virtual-dtor
86-
-Wdelete-non-virtual-dtor
8785
-Werror=non-virtual-dtor
8886
-Werror=delete-non-virtual-dtor
8987

@@ -141,8 +139,6 @@ set(IPC_TOOLKIT_WARNING_FLAGS
141139
-fno-omit-frame-pointer
142140
-fno-optimize-sibling-calls
143141

144-
-Wno-pedantic
145-
146142
-Wno-redundant-decls
147143
)
148144

src/ipc/broad_phase/aabb.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
namespace ipc {
99

10-
AABB::AABB(const ArrayMax3d& min, const ArrayMax3d& max) : min(min), max(max)
10+
AABB::AABB(const ArrayMax3d& _min, const ArrayMax3d& _max)
11+
: min(_min)
12+
, max(_max)
1113
{
1214
assert(min.size() == max.size());
1315
assert((min <= max).all());

src/ipc/broad_phase/hash_grid.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <tbb/parallel_for.h>
1010
#include <tbb/parallel_sort.h>
1111

12-
#include <algorithm> // std::min/max
12+
#include <algorithm> // std::min/max
1313

1414
#define IPC_TOOLKIT_HASH_GRID_USE_SORT_UNIQUE // else use unordered_set
1515

@@ -149,20 +149,22 @@ void HashGrid::detect_candidates(
149149
size_t num_items = items0.size() + items1.size();
150150
std::vector<long> merged_item_indices;
151151
merged_item_indices.reserve(num_items);
152-
long i = 0, j = 0;
153-
while (i < items0.size() && j < items1.size()) {
154-
if (items0[i] < items1[j]) {
152+
{
153+
long i = 0, j = 0;
154+
while (i < items0.size() && j < items1.size()) {
155+
if (items0[i] < items1[j]) {
156+
merged_item_indices.push_back(-(i++) - 1);
157+
} else {
158+
merged_item_indices.push_back(j++);
159+
}
160+
}
161+
while (i < items0.size()) {
155162
merged_item_indices.push_back(-(i++) - 1);
156-
} else {
163+
}
164+
while (j < items1.size()) {
157165
merged_item_indices.push_back(j++);
158166
}
159167
}
160-
while (i < items0.size()) {
161-
merged_item_indices.push_back(-(i++) - 1);
162-
}
163-
while (j < items1.size()) {
164-
merged_item_indices.push_back(j++);
165-
}
166168
assert(merged_item_indices.size() == num_items);
167169

168170
const auto get_item = [&](long i) -> const HashItem& {

src/ipc/broad_phase/hash_grid.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct HashItem {
1010
long id; /// @brief The value of the item.
1111

1212
/// @brief Construct a hash item as a (key, value) pair.
13-
HashItem(int key, int id) : key(key), id(id) { }
13+
HashItem(int _key, int _id) : key(_key), id(_id) { }
1414

1515
/// @brief Compare HashItems by their keys for sorting.
1616
bool operator<(const HashItem& other) const

src/ipc/broad_phase/sweep_and_tiniest_queue.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ namespace ipc {
1212

1313
void SweepAndTiniestQueue::build(
1414
const Eigen::MatrixXd& vertices,
15-
const Eigen::MatrixXi& edges,
16-
const Eigen::MatrixXi& faces,
15+
const Eigen::MatrixXi& _edges,
16+
const Eigen::MatrixXi& _faces,
1717
double inflation_radius)
1818
{
19-
build(vertices, vertices, edges, faces, inflation_radius);
19+
build(vertices, vertices, _edges, _faces, inflation_radius);
2020
}
2121

2222
void SweepAndTiniestQueue::build(
2323
const Eigen::MatrixXd& vertices_t0,
2424
const Eigen::MatrixXd& vertices_t1,
25-
const Eigen::MatrixXi& edges,
26-
const Eigen::MatrixXi& faces,
25+
const Eigen::MatrixXi& _edges,
26+
const Eigen::MatrixXi& _faces,
2727
double inflation_radius)
2828
{
29-
CopyMeshBroadPhase::copy_mesh(edges, faces);
29+
CopyMeshBroadPhase::copy_mesh(_edges, _faces);
3030
num_vertices = vertices_t0.rows();
3131
stq::cpu::constructBoxes(
3232
vertices_t0, vertices_t1, edges, faces, boxes, inflation_radius);
@@ -122,23 +122,23 @@ bool SweepAndTiniestQueue::is_face(long id) const
122122
#ifdef IPC_TOOLKIT_WITH_CUDA
123123
void SweepAndTiniestQueueGPU::build(
124124
const Eigen::MatrixXd& vertices,
125-
const Eigen::MatrixXi& edges,
126-
const Eigen::MatrixXi& faces,
125+
const Eigen::MatrixXi& _edges,
126+
const Eigen::MatrixXi& _faces,
127127
double inflation_radius)
128128
{
129-
CopyMeshBroadPhase::copy_mesh(edges, faces);
129+
CopyMeshBroadPhase::copy_mesh(_edges, _faces);
130130
ccd::gpu::construct_static_collision_candidates(
131131
vertices, edges, faces, overlaps, boxes, inflation_radius);
132132
}
133133

134134
void SweepAndTiniestQueueGPU::build(
135135
const Eigen::MatrixXd& vertices_t0,
136136
const Eigen::MatrixXd& vertices_t1,
137-
const Eigen::MatrixXi& edges,
138-
const Eigen::MatrixXi& faces,
137+
const Eigen::MatrixXi& _edges,
138+
const Eigen::MatrixXi& _faces,
139139
double inflation_radius)
140140
{
141-
CopyMeshBroadPhase::copy_mesh(edges, faces);
141+
CopyMeshBroadPhase::copy_mesh(_edges, _faces);
142142
ccd::gpu::construct_continuous_collision_candidates(
143143
vertices_t0, vertices_t1, edges, faces, overlaps, boxes,
144144
inflation_radius);

src/ipc/broad_phase/sweep_and_tiniest_queue.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ class SweepAndTiniestQueue : public CopyMeshBroadPhase {
5959

6060
/// @brief Find the candidate vertex-vertex collisions.
6161
/// @param[out] candidates The candidate vertex-vertex collisisons.
62-
void detect_vertex_vertex_candidates(
62+
[[noreturn]] void detect_vertex_vertex_candidates(
6363
std::vector<VertexVertexCandidate>& candidates) const override;
6464

6565
/// @brief Find the candidate edge-vertex collisisons.
6666
/// @param[out] candidates The candidate edge-vertex collisisons.
67-
void detect_edge_vertex_candidates(
67+
[[noreturn]] void detect_edge_vertex_candidates(
6868
std::vector<EdgeVertexCandidate>& candidates) const override;
6969

7070
/// @brief Find the candidate edge-edge collisions.
@@ -79,7 +79,7 @@ class SweepAndTiniestQueue : public CopyMeshBroadPhase {
7979

8080
/// @brief Find the candidate edge-face intersections.
8181
/// @param[out] candidates The candidate edge-face intersections.
82-
void detect_edge_face_candidates(
82+
[[noreturn]] void detect_edge_face_candidates(
8383
std::vector<EdgeFaceCandidate>& candidates) const override;
8484

8585
protected:
@@ -127,12 +127,12 @@ class SweepAndTiniestQueueGPU : public CopyMeshBroadPhase {
127127

128128
/// @brief Find the candidate vertex-vertex collisions.
129129
/// @param[out] candidates The candidate vertex-vertex collisisons.
130-
void detect_vertex_vertex_candidates(
130+
[[noreturn]] void detect_vertex_vertex_candidates(
131131
std::vector<VertexVertexCandidate>& candidates) const override;
132132

133133
/// @brief Find the candidate edge-vertex collisisons.
134134
/// @param[out] candidates The candidate edge-vertex collisisons.
135-
void detect_edge_vertex_candidates(
135+
[[noreturn]] void detect_edge_vertex_candidates(
136136
std::vector<EdgeVertexCandidate>& candidates) const override;
137137

138138
/// @brief Find the candidate edge-edge collisions.
@@ -147,7 +147,7 @@ class SweepAndTiniestQueueGPU : public CopyMeshBroadPhase {
147147

148148
/// @brief Find the candidate edge-face intersections.
149149
/// @param[out] candidates The candidate edge-face intersections.
150-
void detect_edge_face_candidates(
150+
[[noreturn]] void detect_edge_face_candidates(
151151
std::vector<EdgeFaceCandidate>& candidates) const override;
152152

153153
private:

src/ipc/broad_phase/voxel_size_heuristic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ double mean_edge_length(
8686

8787
double sum = 0;
8888
for (int i = 0; i < edges.rows(); i++) {
89-
const size_t e0i = edges(i, 0), e1i = edges(i, 1);
89+
const int e0i = edges(i, 0), e1i = edges(i, 1);
9090
sum += (vertices_t0.row(e0i) - vertices_t0.row(e1i)).norm();
9191
sum += (vertices_t1.row(e0i) - vertices_t1.row(e1i)).norm();
9292
}
9393
const double mean = sum / (2 * edges.rows());
9494

9595
std_deviation = 0;
9696
for (int i = 0; i < edges.rows(); i++) {
97-
const size_t e0i = edges(i, 0), e1i = edges(i, 1);
97+
const int e0i = edges(i, 0), e1i = edges(i, 1);
9898
std_deviation += std::pow(
9999
(vertices_t0.row(e0i) - vertices_t0.row(e1i)).norm() - mean, 2);
100100
std_deviation += std::pow(

src/ipc/candidates/candidates.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
namespace ipc {
1515

16-
bool implements_vertex_vertex(const BroadPhaseMethod method)
17-
{
18-
return method != BroadPhaseMethod::SWEEP_AND_TINIEST_QUEUE
19-
&& method != BroadPhaseMethod::SWEEP_AND_TINIEST_QUEUE_GPU;
20-
}
16+
namespace {
17+
bool implements_vertex_vertex(const BroadPhaseMethod method)
18+
{
19+
return method != BroadPhaseMethod::SWEEP_AND_TINIEST_QUEUE
20+
&& method != BroadPhaseMethod::SWEEP_AND_TINIEST_QUEUE_GPU;
21+
}
22+
} // namespace
2123

2224
void Candidates::build(
2325
const CollisionMesh& mesh,

src/ipc/candidates/edge_edge.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace ipc {
77

8-
EdgeEdgeCandidate::EdgeEdgeCandidate(long edge0_id, long edge1_id)
9-
: edge0_id(edge0_id)
10-
, edge1_id(edge1_id)
8+
EdgeEdgeCandidate::EdgeEdgeCandidate(long _edge0_id, long _edge1_id)
9+
: edge0_id(_edge0_id)
10+
, edge1_id(_edge1_id)
1111
{
1212
}
1313

src/ipc/candidates/edge_face.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace ipc {
44

5-
EdgeFaceCandidate::EdgeFaceCandidate(long edge_id, long face_id)
6-
: edge_id(edge_id)
7-
, face_id(face_id)
5+
EdgeFaceCandidate::EdgeFaceCandidate(long _edge_id, long _face_id)
6+
: edge_id(_edge_id)
7+
, face_id(_face_id)
88
{
99
}
1010

0 commit comments

Comments
 (0)