Skip to content

Commit

Permalink
vfvalue.h: reordered members to avoid explicit padding
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Sep 20, 2024
1 parent f1a86d7 commit 560e1da
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions lib/vfvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,32 @@ namespace ValueFlow

enum class LifetimeScope : std::uint8_t { Local, Argument, SubFunction, ThisPointer, ThisValue } lifetimeScope = LifetimeScope::Local;

long long : 24; // padding
enum class LifetimeKind : std::uint8_t {
// Pointer points to a member of lifetime
Object,
// A member of object points to the lifetime
SubObject,
// Lambda has captured lifetime(similar to SubObject)
Lambda,
// Iterator points to the lifetime of a container(similar to Object)
Iterator,
// A pointer that holds the address of the lifetime
Address
} lifetimeKind = LifetimeKind::Object;

/** How known is this value */
enum class ValueKind : std::uint8_t {
/** This value is possible, other unlisted values may also be possible */
Possible,
/** Only listed values are possible */
Known,
/** Inconclusive */
Inconclusive,
/** Listed values are impossible */
Impossible
} valueKind = ValueKind::Possible;

std::int8_t indirect{}; // TODO: can we reduce the size?

/** int value (or sometimes bool value?) */
long long intvalue{};
Expand All @@ -309,9 +334,7 @@ namespace ValueFlow
/** For calculated values - varId that calculated value depends on */
nonneg int varId{};

std::uint8_t indirect{};

long long : 24; // padding
long long : 32; // padding

/** Path id */
MathLib::bigint path{};
Expand All @@ -324,36 +347,11 @@ namespace ValueFlow
// Set to where a lifetime is captured by value
const Token* capturetok{};

enum class LifetimeKind : std::uint8_t {
// Pointer points to a member of lifetime
Object,
// A member of object points to the lifetime
SubObject,
// Lambda has captured lifetime(similar to SubObject)
Lambda,
// Iterator points to the lifetime of a container(similar to Object)
Iterator,
// A pointer that holds the address of the lifetime
Address
} lifetimeKind = LifetimeKind::Object;

static const char* toString(MoveKind moveKind);
static const char* toString(LifetimeKind lifetimeKind);
static const char* toString(LifetimeScope lifetimeScope);
static const char* toString(Bound bound);

/** How known is this value */
enum class ValueKind : std::uint8_t {
/** This value is possible, other unlisted values may also be possible */
Possible,
/** Only listed values are possible */
Known,
/** Inconclusive */
Inconclusive,
/** Listed values are impossible */
Impossible
} valueKind = ValueKind::Possible;

void setKnown() {
valueKind = ValueKind::Known;
}
Expand Down Expand Up @@ -418,8 +416,6 @@ namespace ValueFlow
x--;
}
};

long long : 48; // padding
};
}

Expand Down

0 comments on commit 560e1da

Please sign in to comment.