From b2f15fdbb17cea922928678eb2f7afacb061cb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 24 Jul 2022 10:17:11 +0200 Subject: [PATCH] reduced padding in some classes/structs (#4295) --- cli/CMakeLists.txt | 2 +- lib/symboldatabase.cpp | 4 ++-- lib/symboldatabase.h | 2 +- lib/token.h | 37 ++++++++++++++++++------------------- lib/valueflow.cpp | 2 +- lib/valueflow.h | 16 ++++++++-------- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 3b99ac1b2..aee67e6c2 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -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) # 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() list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $ $ $) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index e7923df32..e285c9839 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2303,11 +2303,11 @@ Function::Function(const Tokenizer *mTokenizer, nestedIn(scope), initArgCount(0), type(eFunction), - access(AccessControl::Public), noexceptArg(nullptr), throwArg(nullptr), templateDef(nullptr), functionPointerUsage(nullptr), + access(AccessControl::Public), mFlags(0) { // operator function @@ -2423,11 +2423,11 @@ Function::Function(const Token *tokenDef, const std::string &clangType) nestedIn(nullptr), initArgCount(0), type(eFunction), - access(AccessControl::Public), noexceptArg(nullptr), throwArg(nullptr), templateDef(nullptr), functionPointerUsage(nullptr), + access(AccessControl::Public), mFlags(0) { // operator function diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 984d3f367..82df2c294 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -918,11 +918,11 @@ public: std::list argumentList; ///< argument list nonneg int initArgCount; ///< number of args with default values Type type; ///< constructor, destructor, ... - AccessControl access; ///< public/protected/private const Token *noexceptArg; ///< noexcept token const Token *throwArg; ///< throw token const Token *templateDef; ///< points to 'template <' before function 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; diff --git a/lib/token.h b/lib/token.h index 681c7ec75..4498fd1e0 100644 --- a/lib/token.h +++ b/lib/token.h @@ -74,6 +74,20 @@ struct TokenImpl { nonneg int mColumn; 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.. Token *mAstOperand1; Token *mAstOperand2; @@ -88,17 +102,6 @@ struct TokenImpl { 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 std::string* mOriginalName; @@ -126,9 +129,6 @@ struct TokenImpl { // For memoization, to speed up parsing of huge arrays #8897 enum class Cpp11init {UNKNOWN, CPP11INIT, NOINIT} mCpp11init; - /** Bitfield bit count. */ - unsigned char mBits; - TokenDebug mDebug; void setCppcheckAttribute(CppcheckAttributes::Type type, MathLib::bigint value); @@ -140,14 +140,14 @@ struct TokenImpl { mLineNumber(0), mColumn(0), mExprId(0), + mProgressValue(0), + mIndex(0), + mBits(0), mAstOperand1(nullptr), mAstOperand2(nullptr), mAstParent(nullptr), mScope(nullptr), - mFunction(nullptr) // Initialize whole union - , - mProgressValue(0), - mIndex(0), + mFunction(nullptr), // Initialize whole union mOriginalName(nullptr), mValueType(nullptr), mValues(nullptr), @@ -155,7 +155,6 @@ struct TokenImpl { mScopeInfo(nullptr), mCppcheckAttributes(nullptr), mCpp11init(Cpp11init::UNKNOWN), - mBits(0), mDebug(TokenDebug::None) {} diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 6283b5406..cbc4b0c90 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -8525,7 +8525,6 @@ ValueFlow::Value::Value(const Token* c, long long val, Bound b) intvalue(val), tokvalue(nullptr), floatValue(0.0), - moveKind(MoveKind::NonMovedVariable), varvalue(val), condition(c), varId(0), @@ -8534,6 +8533,7 @@ ValueFlow::Value::Value(const Token* c, long long val, Bound b) macro(false), defaultArg(false), indirect(0), + moveKind(MoveKind::NonMovedVariable), path(0), wideintvalue(0), subexpressions(), diff --git a/lib/valueflow.h b/lib/valueflow.h index 8f699dc6a..af922035c 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -93,7 +93,6 @@ namespace ValueFlow { intvalue(val), tokvalue(nullptr), floatValue(0.0), - moveKind(MoveKind::NonMovedVariable), varvalue(val), condition(nullptr), varId(0U), @@ -102,6 +101,7 @@ namespace ValueFlow { macro(false), defaultArg(false), indirect(0), + moveKind(MoveKind::NonMovedVariable), path(0), wideintvalue(val), subexpressions(), @@ -331,9 +331,6 @@ namespace ValueFlow { /** float value */ double floatValue; - /** kind of moved */ - enum class MoveKind {NonMovedVariable, MovedVariable, ForwardedVariable} moveKind; - /** For calculated values - variable value that calculated value depends on */ long long varvalue; @@ -361,6 +358,9 @@ namespace ValueFlow { int indirect; + /** kind of moved */ + enum class MoveKind {NonMovedVariable, MovedVariable, ForwardedVariable} moveKind; + /** Path id */ MathLib::bigint path; @@ -472,18 +472,18 @@ bool isContainerSizeChanged(const Token* tok, const Settings* settings = nullptr struct LifetimeToken { const Token* token; - bool addressOf; ValueFlow::Value::ErrorPath errorPath; + bool addressOf; 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) - : 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) - : token(token), addressOf(addressOf), errorPath(std::move(errorPath)), inconclusive(false) + : token(token), errorPath(std::move(errorPath)), addressOf(addressOf), inconclusive(false) {} static std::vector setAddressOf(std::vector v, bool b) {