3333#include < type_traits>
3434#include < vector>
3535
36+ FORCE_WARNING_CLANG_PUSH (" -Wpadded" )
37+
3638class Token;
3739
3840namespace ValueFlow
@@ -43,6 +45,10 @@ namespace ValueFlow
4345
4446 explicit Value (long long val = 0 , Bound b = Bound::Point) :
4547 bound(b),
48+ safe(false ),
49+ conditional(false ),
50+ macro(false ),
51+ defaultArg(false ),
4652 intvalue(val),
4753 varvalue(val),
4854 wideintvalue(val)
@@ -262,6 +268,53 @@ namespace ValueFlow
262268 /* * The value bound */
263269 Bound bound = Bound::Point;
264270
271+ /* * value relies on safe checking */
272+ // cppcheck-suppress premium-misra-cpp-2023-12.2.1
273+ bool safe : 1 ;
274+
275+ /* * Conditional value */
276+ bool conditional : 1 ;
277+
278+ /* * Value is is from an expanded macro */
279+ bool macro : 1 ;
280+
281+ /* * Is this value passed as default parameter to the function? */
282+ bool defaultArg : 1 ;
283+
284+ long long : 4 ; // padding
285+
286+ /* * kind of moved */
287+ enum class MoveKind : std::uint8_t { NonMovedVariable, MovedVariable, ForwardedVariable } moveKind = MoveKind::NonMovedVariable;
288+
289+ enum class LifetimeScope : std::uint8_t { Local, Argument, SubFunction, ThisPointer, ThisValue } lifetimeScope = LifetimeScope::Local;
290+
291+ enum class LifetimeKind : std::uint8_t {
292+ // Pointer points to a member of lifetime
293+ Object,
294+ // A member of object points to the lifetime
295+ SubObject,
296+ // Lambda has captured lifetime(similar to SubObject)
297+ Lambda,
298+ // Iterator points to the lifetime of a container(similar to Object)
299+ Iterator,
300+ // A pointer that holds the address of the lifetime
301+ Address
302+ } lifetimeKind = LifetimeKind::Object;
303+
304+ /* * How known is this value */
305+ enum class ValueKind : std::uint8_t {
306+ /* * This value is possible, other unlisted values may also be possible */
307+ Possible,
308+ /* * Only listed values are possible */
309+ Known,
310+ /* * Inconclusive */
311+ Inconclusive,
312+ /* * Listed values are impossible */
313+ Impossible
314+ } valueKind = ValueKind::Possible;
315+
316+ std::int8_t indirect{}; // TODO: can we reduce the size?
317+
265318 /* * int value (or sometimes bool value?) */
266319 long long intvalue{};
267320
@@ -279,35 +332,20 @@ namespace ValueFlow
279332
280333 ErrorPath errorPath;
281334
282- ErrorPath debugPath;
335+ ErrorPath debugPath; // TODO: make lighter by default
283336
284337 /* * For calculated values - varId that calculated value depends on */
285338 nonneg int varId{};
286339
287- enum class UnknownFunctionReturn : uint8_t {
340+ enum class UnknownFunctionReturn : std:: uint8_t {
288341 no, // not unknown function return
289342 outOfMemory, // out of memory
290343 outOfResources, // out of resource
291344 other // other
292345 };
293346 UnknownFunctionReturn unknownFunctionReturn{UnknownFunctionReturn::no};
294347
295- /* * value relies on safe checking */
296- bool safe{};
297-
298- /* * Conditional value */
299- bool conditional{};
300-
301- /* * Value is is from an expanded macro */
302- bool macro{};
303-
304- /* * Is this value passed as default parameter to the function? */
305- bool defaultArg{};
306-
307- int8_t indirect{};
308-
309- /* * kind of moved */
310- enum class MoveKind : std::uint8_t { NonMovedVariable, MovedVariable, ForwardedVariable } moveKind = MoveKind::NonMovedVariable;
348+ long long : 24 ; // padding
311349
312350 /* * Path id */
313351 MathLib::bigint path{};
@@ -320,38 +358,11 @@ namespace ValueFlow
320358 // Set to where a lifetime is captured by value
321359 const Token* capturetok{};
322360
323- enum class LifetimeKind : std::uint8_t {
324- // Pointer points to a member of lifetime
325- Object,
326- // A member of object points to the lifetime
327- SubObject,
328- // Lambda has captured lifetime(similar to SubObject)
329- Lambda,
330- // Iterator points to the lifetime of a container(similar to Object)
331- Iterator,
332- // A pointer that holds the address of the lifetime
333- Address
334- } lifetimeKind = LifetimeKind::Object;
335-
336- enum class LifetimeScope : std::uint8_t { Local, Argument, SubFunction, ThisPointer, ThisValue } lifetimeScope = LifetimeScope::Local;
337-
338361 RET_NONNULL static const char * toString (MoveKind moveKind);
339362 RET_NONNULL static const char * toString (LifetimeKind lifetimeKind);
340363 RET_NONNULL static const char * toString (LifetimeScope lifetimeScope);
341364 RET_NONNULL static const char * toString (Bound bound);
342365
343- /* * How known is this value */
344- enum class ValueKind : std::uint8_t {
345- /* * This value is possible, other unlisted values may also be possible */
346- Possible,
347- /* * Only listed values are possible */
348- Known,
349- /* * Inconclusive */
350- Inconclusive,
351- /* * Listed values are impossible */
352- Impossible
353- } valueKind = ValueKind::Possible;
354-
355366 void setKnown () {
356367 valueKind = ValueKind::Known;
357368 }
@@ -419,4 +430,6 @@ namespace ValueFlow
419430 };
420431}
421432
433+ FORCE_WARNING_CLANG_POP
434+
422435#endif // vfvalueH
0 commit comments