Skip to content

Commit 142592d

Browse files
committed
src: common: addressed clang-tidy warnings
1 parent a1c2b2b commit 142592d

8 files changed

+36
-40
lines changed

src/common/concat_pd.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ struct concat_pd_t : public primitive_desc_t {
112112
init_desc();
113113
}
114114

115-
concat_pd_t(const concat_pd_t &other) : primitive_desc_t(other) {
116-
n_ = other.n_;
117-
concat_dim_ = other.concat_dim_;
118-
dst_md_ = other.dst_md_;
119-
original_dst_ = other.original_dst_;
120-
src_mds_ = other.src_mds_;
121-
src_image_mds_ = other.src_image_mds_;
122-
115+
concat_pd_t(const concat_pd_t &other)
116+
: primitive_desc_t(other)
117+
, n_(other.n_)
118+
, concat_dim_(other.concat_dim_)
119+
, dst_md_(other.dst_md_)
120+
, original_dst_(other.original_dst_)
121+
, src_mds_(other.src_mds_)
122+
, src_image_mds_(other.src_image_mds_) {
123123
init_desc();
124124
}
125125

src/common/ittnotify.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ namespace dnnl {
2424
namespace impl {
2525
namespace itt {
2626

27-
typedef enum {
27+
// GCC treats using and typedef diffently for enums and structs
28+
// https://stackoverflow.com/questions/48613758
29+
typedef enum { // NOLINT(modernize-use-using)
2830
__itt_task_level_none = 0,
2931
__itt_task_level_low,
3032
__itt_task_level_high

src/common/memory_desc_wrapper.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace impl {
3434

3535
/** thin wrapper class over \struct memory_desc_t which allows easy
3636
* manipulations with underlying C structure, which is taken by reference */
37+
// NOLINTNEXTLINE(readability-identifier-naming)
3738
struct memory_desc_wrapper : public c_compatible {
3839
const memory_desc_t *md_;
3940

src/common/memory_tracking.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ struct registry_t {
428428
public:
429429
common_iterator_t(const void *base_ptr_,
430430
const std::unordered_map<key_t, entry_t> &map,
431-
bool is_begin = true) {
432-
base_ptr = base_ptr_;
431+
bool is_begin = true)
432+
: base_ptr(base_ptr_) {
433433
if (is_begin) {
434434
iter = map.cbegin();
435435
} else {

src/common/nstl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void *malloc(size_t size, int alignment);
5555
#endif
5656
void free(void *p);
5757

58-
struct c_compatible {
58+
struct c_compatible { // NOLINT(readability-identifier-naming)
5959
enum { default_alignment = 64 };
6060
static void *operator new(size_t sz) {
6161
return MALLOC(sz, default_alignment);

src/common/reorder_pd.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ struct reorder_pd_t : public primitive_desc_t {
160160
init_desc(src_engine_kind, dst_engine_kind, false);
161161
}
162162

163-
reorder_pd_t(const reorder_pd_t &other) : primitive_desc_t(other) {
164-
src_md_ = other.src_md_;
165-
dst_md_ = other.dst_md_;
166-
163+
reorder_pd_t(const reorder_pd_t &other)
164+
: primitive_desc_t(other)
165+
, src_md_(other.src_md_)
166+
, dst_md_(other.dst_md_) {
167167
init_desc(other.desc_.src_engine_kind, other.desc_.dst_engine_kind,
168168
other.desc_.is_cross_engine);
169169
}

src/common/sum_pd.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ struct sum_pd_t : public primitive_desc_t {
116116
init_desc();
117117
}
118118

119-
sum_pd_t(const sum_pd_t &other) : primitive_desc_t(other) {
120-
n_ = other.n_;
121-
scales_ = other.scales_;
122-
dst_md_ = other.dst_md_;
123-
dst_acc_md_ = other.dst_acc_md_;
124-
src_mds_ = other.src_mds_;
125-
original_dst_md_ = other.original_dst_md_;
126-
119+
sum_pd_t(const sum_pd_t &other)
120+
: primitive_desc_t(other)
121+
, n_(other.n_)
122+
, scales_(other.scales_)
123+
, dst_md_(other.dst_md_)
124+
, dst_acc_md_(other.dst_acc_md_)
125+
, src_mds_(other.src_mds_)
126+
, original_dst_md_(other.original_dst_md_) {
127127
init_desc();
128128
}
129129
sum_pd_t &operator=(const sum_pd_t &other) {

src/common/utils.hpp

+9-16
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct conditional<false, T, F> {
124124
};
125125

126126
template <bool, typename, bool, typename, typename>
127-
struct conditional3 {};
127+
struct conditional3 {}; // NOLINT(readability-identifier-naming)
128128
template <typename T, typename FT, typename FF>
129129
struct conditional3<true, T, false, FT, FF> {
130130
using type = T;
@@ -139,7 +139,7 @@ struct conditional3<false, T, false, FT, FF> {
139139
};
140140

141141
template <bool, typename U, U, U>
142-
struct conditional_v {};
142+
struct conditional_v {}; // NOLINT(readability-identifier-naming)
143143
template <typename U, U t, U f>
144144
struct conditional_v<true, U, t, f> {
145145
static constexpr U value = t;
@@ -252,7 +252,7 @@ inline void array_set(T *arr, const U &val, size_t size) {
252252

253253
namespace product_impl {
254254
template <size_t>
255-
struct int2type {};
255+
struct int2type {}; // NOLINT(readability-identifier-naming)
256256

257257
template <typename T>
258258
constexpr int product_impl(const T *arr, int2type<0>) {
@@ -479,11 +479,10 @@ T pick_by_prop_kind(prop_kind_t prop_kind, const T &val_fwd, const T &val_bwd_d,
479479
}
480480

481481
template <typename Telem, size_t Tdims>
482-
struct array_offset_calculator {
482+
struct array_offset_calculator { // NOLINT(readability-identifier-naming)
483483
template <typename... Targs>
484-
array_offset_calculator(Telem *base, Targs... Fargs) : _dims {Fargs...} {
485-
_base_ptr = base;
486-
}
484+
array_offset_calculator(Telem *base, Targs... Fargs)
485+
: _base_ptr(base), _dims {Fargs...} {}
487486

488487
template <typename... Targs>
489488
array_offset_calculator(std::nullptr_t, Targs... Fargs) = delete;
@@ -824,16 +823,10 @@ using maybe_unique_ptr = std::unique_ptr<T, nop_deleter_t>;
824823
struct nibble2_t {
825824

826825
// constructs a nibble pair from a pair of uint8_t values
827-
nibble2_t(uint8_t low_, uint8_t high_) {
828-
low = low_;
829-
high = high_;
830-
}
826+
nibble2_t(uint8_t low_, uint8_t high_) : low(low_), high(high_) {}
831827

832828
// constructs a nibble pairs from an uin8_t, taking its low and high part
833-
nibble2_t(uint8_t pack_) {
834-
low = pack_ & 0xf;
835-
high = (pack_ >> 4) & 0xf;
836-
}
829+
nibble2_t(uint8_t pack_) : low(pack_ & 0xf), high((pack_ >> 4) & 0xf) {}
837830

838831
// sets low (idx=0) or high (idx=1) nibble.
839832
inline void set(uint8_t val, int idx) {
@@ -869,7 +862,7 @@ static_assert(sizeof(nibble2_t) == 1, "nibble2_t must be 1 byte");
869862
/// printf("%d\t", idx);
870863
/// }
871864
/// output: 0 2 3
872-
class mask_iterator {
865+
class mask_iterator { // NOLINT(readability-identifier-naming)
873866
int mask_;
874867
int index_;
875868

0 commit comments

Comments
 (0)