11// SPDX-License-Identifier: MPL-2.0
2- #ifndef __BITFILLED_BASE_OPS_HPP__
3- #define __BITFILLED_BASE_OPS_HPP__
2+ #pragma once
43
54#include " bitfilled/access.hpp"
65#include " bitfilled/macros.hpp"
@@ -33,12 +32,12 @@ struct copy_cv_reference
3332{
3433 private:
3534 using R = std::remove_reference_t <T>;
36- using U1 = std::conditional_t <std::is_const <R>::value , std::add_const_t <U>, U>;
37- using U2 = std::conditional_t <std::is_volatile <R>::value , std::add_volatile_t <U1>, U1>;
35+ using U1 = std::conditional_t <std::is_const_v <R>, std::add_const_t <U>, U>;
36+ using U2 = std::conditional_t <std::is_volatile_v <R>, std::add_volatile_t <U1>, U1>;
3837 using U3 =
39- std::conditional_t <std::is_lvalue_reference <T>::value , std::add_lvalue_reference_t <U2>, U2>;
38+ std::conditional_t <std::is_lvalue_reference_v <T>, std::add_lvalue_reference_t <U2>, U2>;
4039 using U4 =
41- std::conditional_t <std::is_rvalue_reference <T>::value , std::add_rvalue_reference_t <U3>, U3>;
40+ std::conditional_t <std::is_rvalue_reference_v <T>, std::add_rvalue_reference_t <U3>, U3>;
4241
4342 public:
4443 using type = U4;
@@ -84,8 +83,8 @@ struct bitfield_props
8483 struct
8584 {
8685 T field : size_bits();
87- } s {.field = v};
88- return s .field;
86+ } storage {.field = v};
87+ return storage .field;
8988 }
9089 return v;
9190 }
@@ -150,6 +149,7 @@ struct base
150149 template <typename Tptr>
151150 static void setter (Tptr& ptr, int_type v)
152151 {
152+ // NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
153153 if constexpr (std::is_void_v<decltype ((copy_cv_t <Tptr&, T>)ptr = v)>)
154154 {
155155 (copy_cv_t <Tptr&, T>)ptr = v;
@@ -159,6 +159,7 @@ struct base
159159 // the assignment might return a volatile-qualified reference
160160 // avoid reading it by keeping it a reference, and casting away the qualifier
161161 // all this is to avoid warnings
162+ // NOLINTNEXTLINE(readability-identifier-length)
162163 [[maybe_unused]] auto & _ = const_cast <T&>((copy_cv_t <Tptr&, T>)ptr = v);
163164 }
164165 }
@@ -168,107 +169,105 @@ struct base
168169 static void set_field (BITFILLED_FIELD_PROPS_PARAM_T& bf, TVal value)
169170 requires(is_writeable<bitfield_ops::access()>)
170171 {
171- const auto v = static_cast <int_type>(value);
172+ const auto intval = static_cast <int_type>(value);
172173 if constexpr (!is_readable<bitfield_ops::access ()> or
173174 is_ephemeralwrite<bitfield_ops::access ()>)
174175 {
175- setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::position_field (v ));
176+ setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::position_field (intval ));
176177 }
177178 else
178179 {
179- setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::insert_field (getter (bf), v ));
180+ setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::insert_field (getter (bf), intval ));
180181 }
181182 }
182183 template <std::size_t FIRST_BIT, std::size_t LAST_BIT, typename TVal>
183184 static void set_field (volatile BITFILLED_FIELD_PROPS_PARAM_T& bf, TVal value)
184185 requires(is_writeable<bitfield_ops::access()>)
185186 {
186- const auto v = static_cast <int_type>(value);
187+ const auto intval = static_cast <int_type>(value);
187188 if constexpr (!is_readable<bitfield_ops::access ()> or
188189 is_ephemeralwrite<bitfield_ops::access ()>)
189190 {
190- setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::position_field (v ));
191+ setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::position_field (intval ));
191192 }
192193 else
193194 {
194- setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::insert_field (getter (bf), v ));
195+ setter (bf, bitfield_props<FIRST_BIT, LAST_BIT>::insert_field (getter (bf), intval ));
195196 }
196197 }
197198
198199 template <typename TVal, std::size_t FIRST_BIT, std::size_t LAST_BIT>
199200 static TVal get_field (const BITFILLED_FIELD_PROPS_PARAM_T& bf)
200201 requires(is_readable<bitfield_ops::access()>)
201202 {
202- auto x =
203+ auto typeval =
203204 static_cast <TVal>(bitfield_props<FIRST_BIT, LAST_BIT>::extract_field (getter (bf)));
204- return bitfield_props<FIRST_BIT, LAST_BIT>::sign_extend (x );
205+ return bitfield_props<FIRST_BIT, LAST_BIT>::sign_extend (typeval );
205206 }
206207 template <typename TVal, std::size_t FIRST_BIT, std::size_t LAST_BIT>
207208 static TVal get_field (const volatile BITFILLED_FIELD_PROPS_PARAM_T& bf)
208209 requires(is_readable<bitfield_ops::access()>)
209210 {
210- auto x =
211+ auto typeval =
211212 static_cast <TVal>(bitfield_props<FIRST_BIT, LAST_BIT>::extract_field (getter (bf)));
212- return bitfield_props<FIRST_BIT, LAST_BIT>::sign_extend (x );
213+ return bitfield_props<FIRST_BIT, LAST_BIT>::sign_extend (typeval );
213214 }
214215
215216 template <std::size_t ITEM_SIZE, std::size_t ITEM_COUNT, std::size_t OFFSET, typename TVal>
216217 static void set_item (BITFILLED_FIELDSET_PROPS_PARAM_T& bf, std::size_t index, TVal value)
217218 requires(is_writeable<bitfield_ops::access()>)
218219 {
219- const auto v = static_cast <int_type>(value);
220+ const auto intval = static_cast <int_type>(value);
220221 if constexpr (!is_readable<bitfield_ops::access ()> or
221222 is_ephemeralwrite<bitfield_ops::access ()>)
222223 {
223224 setter (bf, regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::position_field (
224- v , index));
225+ intval , index));
225226 }
226227 else
227228 {
228229 setter (bf, regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::insert_field (
229- getter (bf), v , index));
230+ getter (bf), intval , index));
230231 }
231232 }
232233 template <std::size_t ITEM_SIZE, std::size_t ITEM_COUNT, std::size_t OFFSET, typename TVal>
233234 static void set_item (volatile BITFILLED_FIELDSET_PROPS_PARAM_T& bf, std::size_t index,
234235 TVal value)
235236 requires(is_writeable<bitfield_ops::access()>)
236237 {
237- const auto v = static_cast <int_type>(value);
238+ const auto intval = static_cast <int_type>(value);
238239 if constexpr (!is_readable<bitfield_ops::access ()> or
239240 is_ephemeralwrite<bitfield_ops::access ()>)
240241 {
241242 setter (bf, regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::position_field (
242- v , index));
243+ intval , index));
243244 }
244245 else
245246 {
246247 setter (bf, regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::insert_field (
247- getter (bf), v , index));
248+ getter (bf), intval , index));
248249 }
249250 }
250251
251252 template <typename TVal, std::size_t ITEM_SIZE, std::size_t ITEM_COUNT, std::size_t OFFSET>
252253 static TVal get_item (const BITFILLED_FIELDSET_PROPS_PARAM_T& bf, std::size_t index)
253254 requires(is_readable<bitfield_ops::access()>)
254255 {
255- auto x = static_cast <TVal>(
256+ auto typeval = static_cast <TVal>(
256257 regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::extract_field (getter (bf),
257258 index));
258- return regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::sign_extend (x );
259+ return regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::sign_extend (typeval );
259260 }
260261 template <typename TVal, std::size_t ITEM_SIZE, std::size_t ITEM_COUNT, std::size_t OFFSET>
261262 static TVal get_item (const volatile BITFILLED_FIELDSET_PROPS_PARAM_T& bf, std::size_t index)
262263 requires(is_readable<bitfield_ops::access()>)
263264 {
264- auto x = static_cast <TVal>(
265+ auto typeval = static_cast <TVal>(
265266 regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::extract_field (getter (bf),
266267 index));
267- return regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::sign_extend (x );
268+ return regbitfieldset_props<ITEM_SIZE, ITEM_COUNT, OFFSET>::sign_extend (typeval );
268269 }
269270 };
270271};
271272
272273} // namespace bitfilled
273-
274- #endif // __BITFILLED_BASE_OPS_HPP__
0 commit comments