Skip to content

Commit f4bf6fc

Browse files
clang-tidy: check and fix cppcoreguidelines-pro-type-union-access
1 parent e06c177 commit f4bf6fc

25 files changed

Lines changed: 307 additions & 301 deletions

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Checks: >
2020
-cppcoreguidelines-pro-type-const-cast,
2121
-cppcoreguidelines-pro-type-member-init,
2222
-cppcoreguidelines-pro-type-reinterpret-cast,
23-
-cppcoreguidelines-pro-type-union-access,
2423
-cppcoreguidelines-pro-type-vararg,
2524
-cppcoreguidelines-slicing
2625

include/c_common/enums.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2525
#ifndef INCLUDE_C_COMMON_ENUMS_H_
2626
#define INCLUDE_C_COMMON_ENUMS_H_
2727

28-
enum Which {
28+
enum Which { // NOLINT(cppcoreguidelines-use-enum-class)
2929
/** undirected graph + results: vertex id */
3030
SLOAN = 0, CUTCHILL, KING,
3131
/** directed graph + results: vertex id */

include/c_types/ii_t_rt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4040
#endif
4141

4242
struct II_t_rt {
43-
union {int64_t id; int64_t source; int64_t start_vid;} d1;
44-
union {int64_t value; int64_t target; int64_t end_vid;} d2;
43+
int64_t d1;
44+
int64_t d2;
4545
};
4646

4747

include/coloring/bipartite_driver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Pgr_Bipartite : public pgrouting::Pgr_messages {
8080
int64_t vid = graph[*v].id;
8181
boost::get(partition_map, *v) ==
8282
boost::color_traits <boost::default_color_type>::white() ?
83-
results.push_back({{vid}, {0}}) : results.push_back({{vid}, {1}});
83+
results.push_back({vid, 0}) : results.push_back({vid, 1});
8484
}
8585
return results;
8686
}

include/coloring/sequentialVertexColoring.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ class Pgr_sequentialVertexColoring {
127127
for (boost::tie(v, vend) = vertices(graph.graph); v != vend; ++v) {
128128
int64_t node = graph[*v].id;
129129
auto color = colors[*v];
130-
results.push_back({{node}, {static_cast<int64_t>(color + 1)}});
130+
results.push_back({node, static_cast<int64_t>(color + 1)});
131131
}
132132

133133
// ordering the results in an increasing order of the node id
134134
std::sort(results.begin(), results.end(),
135135
[](const II_t_rt row1, const II_t_rt row2) {
136-
return row1.d1.id < row2.d1.id;
136+
return row1.d1 < row2.d1;
137137
});
138138

139139
return results;

include/components/makeConnected.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Pgr_makeConnected : public pgrouting::Pgr_messages {
9292
int64_t tgt = graph[graph.target(*ei)].id;
9393
log<< "src:" << src<< "tgt:" << tgt <<"\n";
9494
if (newEdge >= edgeCount) {
95-
results[i] = {{src}, {tgt}};
95+
results[i] = {src, tgt};
9696
i++;
9797
}
9898
newEdge++;

include/cpp_common/info_t.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3535

3636
namespace pgrouting {
3737

38-
enum expectType {
38+
enum class expectType {
3939
ANY_INTEGER,
4040
ANY_NUMERICAL,
4141
TEXT,

include/trsp/trspHandler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class TrspHandler : public pgrouting::Pgr_messages {
6767
*
6868
* The "legal" values are indices to vectors
6969
*/
70-
enum Position {ILLEGAL = -1, RC_EDGE = 0, C_EDGE = 1};
70+
enum Position {ILLEGAL = -1, RC_EDGE = 0, C_EDGE = 1}; // NOLINT(cppcoreguidelines-use-enum-class)
7171

7272

7373
class Predecessor {

include/vrp/initials_code.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace pgrouting {
3232
namespace vrp {
3333

3434
/*! Different kinds to insert an order into the vehicle */
35-
enum Initials_code {
35+
enum Initials_code { // NOLINT(cppcoreguidelines-use-enum-class)
3636
OneTruck, /*! All orders in one truck */
3737
OnePerTruck, /*! One Order per truck */
3838
FrontTruck, /*! Insertion, at the front of the truck */

include/vrp/tw_node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace vrp {
5656
*/
5757
class Tw_node : public Dnode {
5858
public:
59-
typedef enum {
59+
typedef enum { // NOLINT(cppcoreguidelines-use-enum-class)
6060
kStart = 0, ///< starting site
6161
kPickup, ///< pickup site
6262
kDelivery, ///< delivery site

0 commit comments

Comments
 (0)