reduced padding in some classes/structs (#4295)

This commit is contained in:
Oliver Stöneberg 2022-07-24 10:17:11 +02:00 committed by GitHub
parent 8a674e110a
commit b2f15fdbb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 32 deletions

View File

@ -12,7 +12,7 @@ target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simp
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
# false positive warning in up to Clang 13 - caused by FD_ZERO macro # false positive warning in up to Clang 13 - caused by FD_ZERO macro
set_source_files_properties(threadexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier) set_source_files_properties(processexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier)
endif() endif()
list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>) list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)

View File

@ -2303,11 +2303,11 @@ Function::Function(const Tokenizer *mTokenizer,
nestedIn(scope), nestedIn(scope),
initArgCount(0), initArgCount(0),
type(eFunction), type(eFunction),
access(AccessControl::Public),
noexceptArg(nullptr), noexceptArg(nullptr),
throwArg(nullptr), throwArg(nullptr),
templateDef(nullptr), templateDef(nullptr),
functionPointerUsage(nullptr), functionPointerUsage(nullptr),
access(AccessControl::Public),
mFlags(0) mFlags(0)
{ {
// operator function // operator function
@ -2423,11 +2423,11 @@ Function::Function(const Token *tokenDef, const std::string &clangType)
nestedIn(nullptr), nestedIn(nullptr),
initArgCount(0), initArgCount(0),
type(eFunction), type(eFunction),
access(AccessControl::Public),
noexceptArg(nullptr), noexceptArg(nullptr),
throwArg(nullptr), throwArg(nullptr),
templateDef(nullptr), templateDef(nullptr),
functionPointerUsage(nullptr), functionPointerUsage(nullptr),
access(AccessControl::Public),
mFlags(0) mFlags(0)
{ {
// operator function // operator function

View File

@ -918,11 +918,11 @@ public:
std::list<Variable> argumentList; ///< argument list std::list<Variable> argumentList; ///< argument list
nonneg int initArgCount; ///< number of args with default values nonneg int initArgCount; ///< number of args with default values
Type type; ///< constructor, destructor, ... Type type; ///< constructor, destructor, ...
AccessControl access; ///< public/protected/private
const Token *noexceptArg; ///< noexcept token const Token *noexceptArg; ///< noexcept token
const Token *throwArg; ///< throw token const Token *throwArg; ///< throw token
const Token *templateDef; ///< points to 'template <' before function const Token *templateDef; ///< points to 'template <' before function
const Token *functionPointerUsage; ///< function pointer usage const Token *functionPointerUsage; ///< function pointer usage
AccessControl access; ///< public/protected/private
bool argsMatch(const Scope *scope, const Token *first, const Token *second, const std::string &path, nonneg int path_length) const; bool argsMatch(const Scope *scope, const Token *first, const Token *second, const std::string &path, nonneg int path_length) const;

View File

@ -74,6 +74,20 @@ struct TokenImpl {
nonneg int mColumn; nonneg int mColumn;
nonneg int mExprId; nonneg int mExprId;
/**
* A value from 0-100 that provides a rough idea about where in the token
* list this token is located.
*/
nonneg int mProgressValue;
/**
* Token index. Position in token list
*/
nonneg int mIndex;
/** Bitfield bit count. */
unsigned char mBits;
// AST.. // AST..
Token *mAstOperand1; Token *mAstOperand1;
Token *mAstOperand2; Token *mAstOperand2;
@ -88,17 +102,6 @@ struct TokenImpl {
const Enumerator *mEnumerator; const Enumerator *mEnumerator;
}; };
/**
* A value from 0-100 that provides a rough idea about where in the token
* list this token is located.
*/
nonneg int mProgressValue;
/**
* Token index. Position in token list
*/
nonneg int mIndex;
// original name like size_t // original name like size_t
std::string* mOriginalName; std::string* mOriginalName;
@ -126,9 +129,6 @@ struct TokenImpl {
// For memoization, to speed up parsing of huge arrays #8897 // For memoization, to speed up parsing of huge arrays #8897
enum class Cpp11init {UNKNOWN, CPP11INIT, NOINIT} mCpp11init; enum class Cpp11init {UNKNOWN, CPP11INIT, NOINIT} mCpp11init;
/** Bitfield bit count. */
unsigned char mBits;
TokenDebug mDebug; TokenDebug mDebug;
void setCppcheckAttribute(CppcheckAttributes::Type type, MathLib::bigint value); void setCppcheckAttribute(CppcheckAttributes::Type type, MathLib::bigint value);
@ -140,14 +140,14 @@ struct TokenImpl {
mLineNumber(0), mLineNumber(0),
mColumn(0), mColumn(0),
mExprId(0), mExprId(0),
mProgressValue(0),
mIndex(0),
mBits(0),
mAstOperand1(nullptr), mAstOperand1(nullptr),
mAstOperand2(nullptr), mAstOperand2(nullptr),
mAstParent(nullptr), mAstParent(nullptr),
mScope(nullptr), mScope(nullptr),
mFunction(nullptr) // Initialize whole union mFunction(nullptr), // Initialize whole union
,
mProgressValue(0),
mIndex(0),
mOriginalName(nullptr), mOriginalName(nullptr),
mValueType(nullptr), mValueType(nullptr),
mValues(nullptr), mValues(nullptr),
@ -155,7 +155,6 @@ struct TokenImpl {
mScopeInfo(nullptr), mScopeInfo(nullptr),
mCppcheckAttributes(nullptr), mCppcheckAttributes(nullptr),
mCpp11init(Cpp11init::UNKNOWN), mCpp11init(Cpp11init::UNKNOWN),
mBits(0),
mDebug(TokenDebug::None) mDebug(TokenDebug::None)
{} {}

View File

@ -8525,7 +8525,6 @@ ValueFlow::Value::Value(const Token* c, long long val, Bound b)
intvalue(val), intvalue(val),
tokvalue(nullptr), tokvalue(nullptr),
floatValue(0.0), floatValue(0.0),
moveKind(MoveKind::NonMovedVariable),
varvalue(val), varvalue(val),
condition(c), condition(c),
varId(0), varId(0),
@ -8534,6 +8533,7 @@ ValueFlow::Value::Value(const Token* c, long long val, Bound b)
macro(false), macro(false),
defaultArg(false), defaultArg(false),
indirect(0), indirect(0),
moveKind(MoveKind::NonMovedVariable),
path(0), path(0),
wideintvalue(0), wideintvalue(0),
subexpressions(), subexpressions(),

View File

@ -93,7 +93,6 @@ namespace ValueFlow {
intvalue(val), intvalue(val),
tokvalue(nullptr), tokvalue(nullptr),
floatValue(0.0), floatValue(0.0),
moveKind(MoveKind::NonMovedVariable),
varvalue(val), varvalue(val),
condition(nullptr), condition(nullptr),
varId(0U), varId(0U),
@ -102,6 +101,7 @@ namespace ValueFlow {
macro(false), macro(false),
defaultArg(false), defaultArg(false),
indirect(0), indirect(0),
moveKind(MoveKind::NonMovedVariable),
path(0), path(0),
wideintvalue(val), wideintvalue(val),
subexpressions(), subexpressions(),
@ -331,9 +331,6 @@ namespace ValueFlow {
/** float value */ /** float value */
double floatValue; double floatValue;
/** kind of moved */
enum class MoveKind {NonMovedVariable, MovedVariable, ForwardedVariable} moveKind;
/** For calculated values - variable value that calculated value depends on */ /** For calculated values - variable value that calculated value depends on */
long long varvalue; long long varvalue;
@ -361,6 +358,9 @@ namespace ValueFlow {
int indirect; int indirect;
/** kind of moved */
enum class MoveKind {NonMovedVariable, MovedVariable, ForwardedVariable} moveKind;
/** Path id */ /** Path id */
MathLib::bigint path; MathLib::bigint path;
@ -472,18 +472,18 @@ bool isContainerSizeChanged(const Token* tok, const Settings* settings = nullptr
struct LifetimeToken { struct LifetimeToken {
const Token* token; const Token* token;
bool addressOf;
ValueFlow::Value::ErrorPath errorPath; ValueFlow::Value::ErrorPath errorPath;
bool addressOf;
bool inconclusive; bool inconclusive;
LifetimeToken() : token(nullptr), addressOf(false), errorPath(), inconclusive(false) {} LifetimeToken() : token(nullptr), errorPath(), addressOf(false), inconclusive(false) {}
LifetimeToken(const Token* token, ValueFlow::Value::ErrorPath errorPath) LifetimeToken(const Token* token, ValueFlow::Value::ErrorPath errorPath)
: token(token), addressOf(false), errorPath(std::move(errorPath)), inconclusive(false) : token(token), errorPath(std::move(errorPath)), addressOf(false), inconclusive(false)
{} {}
LifetimeToken(const Token* token, bool addressOf, ValueFlow::Value::ErrorPath errorPath) LifetimeToken(const Token* token, bool addressOf, ValueFlow::Value::ErrorPath errorPath)
: token(token), addressOf(addressOf), errorPath(std::move(errorPath)), inconclusive(false) : token(token), errorPath(std::move(errorPath)), addressOf(addressOf), inconclusive(false)
{} {}
static std::vector<LifetimeToken> setAddressOf(std::vector<LifetimeToken> v, bool b) { static std::vector<LifetimeToken> setAddressOf(std::vector<LifetimeToken> v, bool b) {