Use in-class initializers, default constructors, class -> struct (#4842)

This commit is contained in:
chrchr-github 2023-08-08 11:05:02 +02:00 committed by GitHub
parent 838b6b86e3
commit eee1221738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 531 additions and 861 deletions

View File

@ -1,5 +1,69 @@
--- ---
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,google-explicit-constructor,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-modernize-use-default-member-init,-readability-redundant-member-init,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-misc-non-private-member-variables-in-classes,-clang-analyzer-*,-bugprone-signed-char-misuse,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness,-portability-std-allocator-const,-modernize-deprecated-ios-base-aliases,-bugprone-unchecked-optional-access,-modernize-replace-auto-ptr,-readability-identifier-naming,-portability-simd-intrinsics,-misc-use-anonymous-namespace,cert-err34-c' Checks: >
*,
-abseil-*,
-altera-*,
-android-*,
-boost-*,
-cert-*,
-cppcoreguidelines-*,
-darwin-*,
-fuchsia-*,
-google-*,
-hicpp-*,
-linuxkernel-*,
-llvm-*,
-llvmlibc-*,
-mpi-*,
-objc-*,
-openmp-*,
-zircon-*,
cert-err34-c,
google-explicit-constructor,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-signed-char-misuse,
-bugprone-unchecked-optional-access,
-clang-analyzer-*,
-concurrency-mt-unsafe,
-misc-const-correctness,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-throw-by-value-catch-by-reference,
-misc-use-anonymous-namespace,
-modernize-avoid-c-arrays,
-modernize-deprecated-ios-base-aliases,
-modernize-loop-convert,
-modernize-raw-string-literal,
-modernize-replace-auto-ptr,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-equals-default,
-modernize-use-trailing-return-type,
-performance-inefficient-string-concatenation,
-performance-no-automatic-move,
-portability-simd-intrinsics,
-portability-std-allocator-const,
-readability-avoid-const-params-in-decls,
-readability-braces-around-statements,
-readability-const-return-type,
-readability-container-data-pointer,
-readability-container-size-empty,
-readability-convert-member-functions-to-static,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-identifier-naming,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-redundant-access-specifiers,
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix,
-readability-use-anyofallof
WarningsAsErrors: '*' WarningsAsErrors: '*'
HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h' HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h'
CheckOptions: CheckOptions:

View File

@ -37,18 +37,16 @@ These are coding guidelines we do not follow. Some of the checks might be explic
`modernize-use-auto`<br> `modernize-use-auto`<br>
`readability-uppercase-literal-suffix`<br> `readability-uppercase-literal-suffix`<br>
`readability-else-after-return`<br> `readability-else-after-return`<br>
`modernize-use-default-member-init`<br>
`readability-identifier-length`<br> `readability-identifier-length`<br>
These do not relect the style we are (currently) enforcing. These do not reflect the style we are (currently) enforcing.
`readability-function-size`<br> `readability-function-size`<br>
`readability-function-cognitive-complexity`<br> `readability-function-cognitive-complexity`<br>
We are not interesting in the size/complexity of a function. We are not interested in the size/complexity of a function.
`readability-magic-numbers`<br> `readability-magic-numbers`<br>
`readability-redundant-member-init`<br>
These do not (always) increase readability. These do not (always) increase readability.
@ -58,7 +56,7 @@ To be documented.
`readability-implicit-bool-conversion`<br> `readability-implicit-bool-conversion`<br>
This does not appear not to be useful as it is reported on very common code. This does not appear to be useful as it is reported on very common code.
`bugprone-narrowing-conversions`<br> `bugprone-narrowing-conversions`<br>
`performance-no-automatic-move`<br> `performance-no-automatic-move`<br>

View File

@ -113,10 +113,6 @@ CmdLineParser::CmdLineParser(Settings &settings, Suppressions &suppressions, Sup
: mSettings(settings) : mSettings(settings)
, mSuppressions(suppressions) , mSuppressions(suppressions)
, mSuppressionsNoFail(suppressionsNoFail) , mSuppressionsNoFail(suppressionsNoFail)
, mShowHelp(false)
, mShowVersion(false)
, mShowErrorMessages(false)
, mExitAfterPrint(false)
{} {}
void CmdLineParser::printMessage(const std::string &message) void CmdLineParser::printMessage(const std::string &message)

View File

@ -146,10 +146,10 @@ private:
Settings &mSettings; Settings &mSettings;
Suppressions &mSuppressions; Suppressions &mSuppressions;
Suppressions &mSuppressionsNoFail; Suppressions &mSuppressionsNoFail;
bool mShowHelp; bool mShowHelp{};
bool mShowVersion; bool mShowVersion{};
bool mShowErrorMessages; bool mShowErrorMessages{};
bool mExitAfterPrint; bool mExitAfterPrint{};
std::string mVSConfig; std::string mVSConfig;
}; };

View File

@ -72,10 +72,6 @@
/*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout; /*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout;
CppCheckExecutor::CppCheckExecutor()
: mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mShowAllErrors(false)
{}
CppCheckExecutor::~CppCheckExecutor() CppCheckExecutor::~CppCheckExecutor()
{ {
delete mErrorOutput; delete mErrorOutput;

View File

@ -46,7 +46,7 @@ public:
/** /**
* Constructor * Constructor
*/ */
CppCheckExecutor(); CppCheckExecutor() = default;
CppCheckExecutor(const CppCheckExecutor &) = delete; CppCheckExecutor(const CppCheckExecutor &) = delete;
void operator=(const CppCheckExecutor&) = delete; void operator=(const CppCheckExecutor&) = delete;
@ -154,7 +154,7 @@ private:
/** /**
* Pointer to current settings; set while check() is running for reportError(). * Pointer to current settings; set while check() is running for reportError().
*/ */
const Settings* mSettings; const Settings* mSettings{};
/** /**
* Used to filter out duplicate error messages. * Used to filter out duplicate error messages.
@ -169,7 +169,7 @@ private:
/** /**
* Report progress time * Report progress time
*/ */
std::time_t mLatestProgressOutputTime; std::time_t mLatestProgressOutputTime{};
/** /**
* Output file name for exception handler * Output file name for exception handler
@ -179,12 +179,12 @@ private:
/** /**
* Error output * Error output
*/ */
std::ofstream *mErrorOutput; std::ofstream* mErrorOutput{};
/** /**
* Has --errorlist been given? * Has --errorlist been given?
*/ */
bool mShowAllErrors; bool mShowAllErrors{};
}; };
#endif // CPPCHECKEXECUTOR_H #endif // CPPCHECKEXECUTOR_H

View File

@ -85,7 +85,7 @@ class ThreadData
{ {
public: public:
ThreadData(ThreadExecutor &threadExecutor, ErrorLogger &errorLogger, const Settings &settings, const std::map<std::string, std::size_t> &files, const std::list<ImportProject::FileSettings> &fileSettings) ThreadData(ThreadExecutor &threadExecutor, ErrorLogger &errorLogger, const Settings &settings, const std::map<std::string, std::size_t> &files, const std::list<ImportProject::FileSettings> &fileSettings)
: mFiles(files), mFileSettings(fileSettings), mProcessedFiles(0), mProcessedSize(0), mSettings(settings), logForwarder(threadExecutor, errorLogger) : mFiles(files), mFileSettings(fileSettings), mSettings(settings), logForwarder(threadExecutor, errorLogger)
{ {
mItNextFile = mFiles.begin(); mItNextFile = mFiles.begin();
mItNextFileSettings = mFileSettings.begin(); mItNextFileSettings = mFileSettings.begin();
@ -148,10 +148,10 @@ private:
const std::list<ImportProject::FileSettings> &mFileSettings; const std::list<ImportProject::FileSettings> &mFileSettings;
std::list<ImportProject::FileSettings>::const_iterator mItNextFileSettings; std::list<ImportProject::FileSettings>::const_iterator mItNextFileSettings;
std::size_t mProcessedFiles; std::size_t mProcessedFiles{};
std::size_t mTotalFiles; std::size_t mTotalFiles{};
std::size_t mProcessedSize; std::size_t mProcessedSize{};
std::size_t mTotalFileSize; std::size_t mTotalFileSize{};
std::mutex mFileSync; std::mutex mFileSync;
const Settings &mSettings; const Settings &mSettings;

View File

@ -27,8 +27,7 @@
#include <QVariant> #include <QVariant>
ApplicationList::ApplicationList(QObject *parent) : ApplicationList::ApplicationList(QObject *parent) :
QObject(parent), QObject(parent)
mDefaultApplicationIndex(-1)
{ {
//ctor //ctor
} }

View File

@ -133,7 +133,7 @@ private:
* @brief Index of the default application. * @brief Index of the default application.
* *
*/ */
int mDefaultApplicationIndex; int mDefaultApplicationIndex = -1;
}; };
/// @} /// @}
#endif // APPLICATIONLIST_H #endif // APPLICATIONLIST_H

View File

@ -84,10 +84,8 @@ static bool executeCommand(std::string exe, std::vector<std::string> args, std::
CheckThread::CheckThread(ThreadResult &result) : CheckThread::CheckThread(ThreadResult &result) :
mState(Ready),
mResult(result), mResult(result),
mCppcheck(result, true, executeCommand), mCppcheck(result, true, executeCommand)
mAnalyseWholeProgram(false)
{ {
//ctor //ctor
} }

View File

@ -120,7 +120,7 @@ protected:
/** /**
* @brief Thread's current execution state. * @brief Thread's current execution state.
*/ */
State mState; State mState = Ready;
ThreadResult &mResult; ThreadResult &mResult;
/** /**
@ -136,7 +136,7 @@ private:
bool isSuppressed(const Suppressions::ErrorMessage &errorMessage) const; bool isSuppressed(const Suppressions::ErrorMessage &errorMessage) const;
QStringList mFiles; QStringList mFiles;
bool mAnalyseWholeProgram; bool mAnalyseWholeProgram{};
QStringList mAddonsAndTools; QStringList mAddonsAndTools;
QStringList mClangIncludePaths; QStringList mClangIncludePaths;
QList<Suppressions::Suppression> mSuppressions; QList<Suppressions::Suppression> mSuppressions;

View File

@ -42,7 +42,6 @@ CodeEditorStyle::CodeEditorStyle(
// cppcheck-suppress naming-varname - TODO: fix this // cppcheck-suppress naming-varname - TODO: fix this
QColor SymbFGColor, QColor SymbBGColor, QColor SymbFGColor, QColor SymbBGColor,
const QFont::Weight& SymbWeight) : const QFont::Weight& SymbWeight) :
mSystemTheme(false),
widgetFGColor(std::move(CtrlFGColor)), widgetFGColor(std::move(CtrlFGColor)),
widgetBGColor(std::move(CtrlBGColor)), widgetBGColor(std::move(CtrlBGColor)),
highlightBGColor(std::move(HiLiBGColor)), highlightBGColor(std::move(HiLiBGColor)),

View File

@ -81,7 +81,7 @@ public:
static void saveSettings(QSettings *settings, const CodeEditorStyle& theStyle); static void saveSettings(QSettings *settings, const CodeEditorStyle& theStyle);
public: public:
bool mSystemTheme; bool mSystemTheme{};
QColor widgetFGColor; QColor widgetFGColor;
QColor widgetBGColor; QColor widgetBGColor;
QColor highlightBGColor; QColor highlightBGColor;

View File

@ -69,8 +69,7 @@ const QColor& SelectColorButton::getColor()
} }
SelectFontWeightCombo::SelectFontWeightCombo(QWidget* parent) : SelectFontWeightCombo::SelectFontWeightCombo(QWidget* parent) :
QComboBox(parent), QComboBox(parent)
mWeight(QFont::Normal)
{ {
addItem(QObject::tr("Thin"), addItem(QObject::tr("Thin"),
QVariant(static_cast<int>(QFont::Thin))); QVariant(static_cast<int>(QFont::Thin)));

View File

@ -71,7 +71,7 @@ public slots:
void changeWeight(int index); void changeWeight(int index);
private: private:
QFont::Weight mWeight; QFont::Weight mWeight = QFont::Normal;
}; };
#endif //CODEEDITORSTYLECONTROLS_H #endif //CODEEDITORSTYLECONTROLS_H

View File

@ -33,8 +33,6 @@ public:
CppcheckLibraryData(); CppcheckLibraryData();
struct Container { struct Container {
Container() : access_arrayLike(false), size_templateParameter(-1) {}
QString id; QString id;
QString inherits; QString inherits;
QString startPattern; QString startPattern;
@ -42,8 +40,8 @@ public:
QString opLessAllowed; QString opLessAllowed;
QString itEndPattern; QString itEndPattern;
bool access_arrayLike; bool access_arrayLike{};
int size_templateParameter; int size_templateParameter = -1;
struct { struct {
QString templateParameter; QString templateParameter;
@ -72,21 +70,17 @@ public:
}; };
struct Function { struct Function {
Function() : noreturn(Unknown), gccPure(false), gccConst(false),
leakignore(false), useretval(false) {}
QString comments; QString comments;
QString name; QString name;
enum TrueFalseUnknown { False, True, Unknown } noreturn; enum TrueFalseUnknown { False, True, Unknown } noreturn = Unknown;
bool gccPure; bool gccPure{};
bool gccConst; bool gccConst{};
bool leakignore; bool leakignore{};
bool useretval; bool useretval{};
struct ReturnValue { struct ReturnValue {
ReturnValue() : container(-1) {}
QString type; QString type;
QString value; QString value;
int container; int container = -1;
bool empty() const { bool empty() const {
return type.isNull() && value.isNull() && container < 0; return type.isNull() && value.isNull() && container < 0;
} }
@ -96,19 +90,16 @@ public:
QString secure; QString secure;
} formatstr; } formatstr;
struct Arg { struct Arg {
Arg() : nr(0), notbool(false), notnull(false), notuninit(false),
formatstr(false), strz(false) {}
QString name; QString name;
unsigned int nr; unsigned int nr{};
static const unsigned int ANY; static const unsigned int ANY;
static const unsigned int VARIADIC; static const unsigned int VARIADIC;
QString defaultValue; QString defaultValue;
bool notbool; bool notbool{};
bool notnull; bool notnull{};
bool notuninit; bool notuninit{};
bool formatstr; bool formatstr{};
bool strz; bool strz{};
QString valid; QString valid;
struct MinSize { struct MinSize {
QString type; QString type;
@ -117,8 +108,7 @@ public:
}; };
QList<struct MinSize> minsizes; QList<struct MinSize> minsizes;
struct Iterator { struct Iterator {
Iterator() : container(-1) {} int container = -1;
int container;
QString type; QString type;
} iterator; } iterator;
}; };
@ -147,26 +137,15 @@ public:
struct MemoryResource { struct MemoryResource {
QString type; // "memory" or "resource" QString type; // "memory" or "resource"
struct Alloc { struct Alloc {
Alloc() : bool isRealloc{};
isRealloc(false), bool init{};
init(false), int arg = -1; // -1: Has no optional "realloc-arg" attribute
arg(-1), // -1: Has no optional "arg" attribute int reallocArg = -1; // -1: Has no optional "arg" attribute
reallocArg(-1) // -1: Has no optional "realloc-arg" attribute
{}
bool isRealloc;
bool init;
int arg;
int reallocArg;
QString bufferSize; QString bufferSize;
QString name; QString name;
}; };
struct Dealloc { struct Dealloc {
Dealloc() : int arg = -1; // -1: Has no optional "arg" attribute
arg(-1) // -1: Has no optional "arg" attribute
{}
int arg;
QString name; QString name;
}; };
@ -193,11 +172,7 @@ public:
struct Reflection { struct Reflection {
struct Call { struct Call {
Call() : int arg = -1; // -1: Mandatory "arg" attribute not available
arg {-1} // -1: Mandatory "arg" attribute not available
{}
int arg;
QString name; QString name;
}; };
@ -206,12 +181,8 @@ public:
struct Markup { struct Markup {
struct CodeBlocks { struct CodeBlocks {
CodeBlocks() :
offset {-1}
{}
QStringList blocks; QStringList blocks;
int offset; int offset = -1;
QString start; QString start;
QString end; QString end;
}; };
@ -223,8 +194,8 @@ public:
}; };
QString ext; QString ext;
bool afterCode; bool afterCode{};
bool reportErrors; bool reportErrors{};
QStringList keywords; QStringList keywords;
QStringList importer; QStringList importer;
QList<CodeBlocks> codeBlocks; QList<CodeBlocks> codeBlocks;
@ -232,12 +203,8 @@ public:
}; };
struct SmartPointer { struct SmartPointer {
SmartPointer() :
unique {false}
{}
QString name; QString name;
bool unique; bool unique{};
}; };
struct Entrypoint { struct Entrypoint {

View File

@ -34,7 +34,7 @@ namespace Ui {
class HelpBrowser : public QTextBrowser { class HelpBrowser : public QTextBrowser {
public: public:
explicit HelpBrowser(QWidget* parent = nullptr) : QTextBrowser(parent), mHelpEngine(nullptr) {} explicit HelpBrowser(QWidget* parent = nullptr) : QTextBrowser(parent) {}
HelpBrowser(const HelpBrowser&) = delete; HelpBrowser(const HelpBrowser&) = delete;
HelpBrowser(HelpBrowser&&) = delete; HelpBrowser(HelpBrowser&&) = delete;
HelpBrowser& operator=(const HelpBrowser&) = delete; HelpBrowser& operator=(const HelpBrowser&) = delete;
@ -42,7 +42,7 @@ public:
void setHelpEngine(QHelpEngine *helpEngine); void setHelpEngine(QHelpEngine *helpEngine);
QVariant loadResource(int type, const QUrl& name) override; QVariant loadResource(int type, const QUrl& name) override;
private: private:
QHelpEngine* mHelpEngine; QHelpEngine* mHelpEngine{};
}; };
class HelpDialog : public QDialog { class HelpDialog : public QDialog {

View File

@ -61,8 +61,7 @@ public:
LibraryDialog::LibraryDialog(QWidget *parent) : LibraryDialog::LibraryDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
mUi(new Ui::LibraryDialog), mUi(new Ui::LibraryDialog)
mIgnoreChanges(false)
{ {
mUi->setupUi(this); mUi->setupUi(this);
mUi->buttonSave->setEnabled(false); mUi->buttonSave->setEnabled(false);

View File

@ -56,7 +56,7 @@ private:
Ui::LibraryDialog *mUi; Ui::LibraryDialog *mUi;
CppcheckLibraryData mData; CppcheckLibraryData mData;
QString mFileName; QString mFileName;
bool mIgnoreChanges; bool mIgnoreChanges{};
static QString getArgText(const CppcheckLibraryData::Function::Arg &arg); static QString getArgText(const CppcheckLibraryData::Function::Arg &arg);
CppcheckLibraryData::Function *currentFunction(); CppcheckLibraryData::Function *currentFunction();

View File

@ -109,14 +109,10 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mApplications(new ApplicationList(this)), mApplications(new ApplicationList(this)),
mTranslation(th), mTranslation(th),
mUI(new Ui::MainWindow), mUI(new Ui::MainWindow),
mScratchPad(nullptr),
mProjectFile(nullptr),
mPlatformActions(new QActionGroup(this)), mPlatformActions(new QActionGroup(this)),
mCStandardActions(new QActionGroup(this)), mCStandardActions(new QActionGroup(this)),
mCppStandardActions(new QActionGroup(this)), mCppStandardActions(new QActionGroup(this)),
mSelectLanguageActions(new QActionGroup(this)), mSelectLanguageActions(new QActionGroup(this))
mExiting(false),
mIsLogfileLoaded(false)
{ {
{ {
Settings tempSettings; Settings tempSettings;

View File

@ -437,10 +437,10 @@ private:
QString mCurrentDirectory; QString mCurrentDirectory;
/** @brief Scratchpad. */ /** @brief Scratchpad. */
ScratchPad* mScratchPad; ScratchPad* mScratchPad{};
/** @brief Project (file). */ /** @brief Project (file). */
ProjectFile *mProjectFile; ProjectFile* mProjectFile{};
/** @brief Filter field in the Filter toolbar. */ /** @brief Filter field in the Filter toolbar. */
QLineEdit* mLineEditFilter; QLineEdit* mLineEditFilter;
@ -462,10 +462,10 @@ private:
* If this is true then the cppcheck is waiting for check threads to exit * If this is true then the cppcheck is waiting for check threads to exit
* so that the application can be closed. * so that the application can be closed.
*/ */
bool mExiting; bool mExiting{};
/** @brief Set to true in case of loading log file. */ /** @brief Set to true in case of loading log file. */
bool mIsLogfileLoaded; bool mIsLogfileLoaded{};
/** /**
* @brief Project MRU menu actions. * @brief Project MRU menu actions.

View File

@ -23,7 +23,6 @@
#include <QIODevice> #include <QIODevice>
Report::Report(QString filename) : Report::Report(QString filename) :
QObject(),
mFilename(std::move(filename)) mFilename(std::move(filename))
{} {}

View File

@ -81,19 +81,7 @@ static const int COLUMN_SINCE_DATE = 6;
static const int COLUMN_TAGS = 7; static const int COLUMN_TAGS = 7;
ResultsTree::ResultsTree(QWidget * parent) : ResultsTree::ResultsTree(QWidget * parent) :
QTreeView(parent), QTreeView(parent)
mSettings(nullptr),
mApplications(nullptr),
mContextItem(nullptr),
mShowFullPath(false),
mSaveFullPath(false),
mSaveAllErrors(true),
mShowErrorId(false),
mVisibleErrors(false),
mSelectionModel(nullptr),
mThread(nullptr),
mShowCppcheck(true),
mShowClang(true)
{ {
setModel(&mModel); setModel(&mModel);
translate(); // Adds columns to grid translate(); // Adds columns to grid

View File

@ -453,7 +453,7 @@ protected:
* @brief Program settings * @brief Program settings
* *
*/ */
QSettings *mSettings; QSettings* mSettings{};
/** /**
* @brief A string used to filter the results for display. * @brief A string used to filter the results for display.
@ -465,37 +465,37 @@ protected:
* @brief List of applications to open errors with * @brief List of applications to open errors with
* *
*/ */
ApplicationList *mApplications; ApplicationList* mApplications{};
/** /**
* @brief Right clicked item (used by context menu slots) * @brief Right clicked item (used by context menu slots)
* *
*/ */
QStandardItem *mContextItem; QStandardItem* mContextItem{};
/** /**
* @brief Should full path of files be shown (true) or relative (false) * @brief Should full path of files be shown (true) or relative (false)
* *
*/ */
bool mShowFullPath; bool mShowFullPath{};
/** /**
* @brief Should full path of files be saved * @brief Should full path of files be saved
* *
*/ */
bool mSaveFullPath; bool mSaveFullPath{};
/** /**
* @brief Save all errors (true) or only visible (false) * @brief Save all errors (true) or only visible (false)
* *
*/ */
bool mSaveAllErrors; bool mSaveAllErrors = true;
/** /**
* @brief true if optional column "Id" is shown * @brief true if optional column "Id" is shown
* *
*/ */
bool mShowErrorId; bool mShowErrorId{};
/** /**
* @brief Path we are currently checking * @brief Path we are currently checking
@ -507,7 +507,7 @@ protected:
* @brief Are there any visible errors * @brief Are there any visible errors
* *
*/ */
bool mVisibleErrors; bool mVisibleErrors{};
private: private:
/** tag selected items */ /** tag selected items */
@ -518,11 +518,11 @@ private:
QStringList mHiddenMessageId; QStringList mHiddenMessageId;
QItemSelectionModel *mSelectionModel; QItemSelectionModel* mSelectionModel{};
ThreadHandler *mThread; ThreadHandler *mThread{};
bool mShowCppcheck; bool mShowCppcheck = true;
bool mShowClang; bool mShowClang = true;
}; };
/// @} /// @}
#endif // RESULTSTREE_H #endif // RESULTSTREE_H

View File

@ -67,7 +67,6 @@
ResultsView::ResultsView(QWidget * parent) : ResultsView::ResultsView(QWidget * parent) :
QWidget(parent), QWidget(parent),
mShowNoErrorsMessage(true),
mUI(new Ui::ResultsView), mUI(new Ui::ResultsView),
mStatistics(new CheckStatistics(this)) mStatistics(new CheckStatistics(this))
{ {

View File

@ -344,7 +344,7 @@ protected:
/** /**
* @brief Should we show a "No errors found dialog" every time no errors were found? * @brief Should we show a "No errors found dialog" every time no errors were found?
*/ */
bool mShowNoErrorsMessage; bool mShowNoErrorsMessage = true;
Ui::ResultsView *mUI; Ui::ResultsView *mUI;

View File

@ -71,8 +71,7 @@ static const QString CPPCHECK("cppcheck");
StatsDialog::StatsDialog(QWidget *parent) StatsDialog::StatsDialog(QWidget *parent)
: QDialog(parent), : QDialog(parent),
mUI(new Ui::StatsDialog), mUI(new Ui::StatsDialog)
mStatistics(nullptr)
{ {
mUI->setupUi(this); mUI->setupUi(this);

View File

@ -73,7 +73,7 @@ private slots:
void pdfExport(); void pdfExport();
private: private:
Ui::StatsDialog *mUI; Ui::StatsDialog *mUI;
const CheckStatistics *mStatistics; const CheckStatistics* mStatistics{};
}; };
/// @} /// @}

View File

@ -39,9 +39,8 @@ const char Settings::SafeChecks::XmlClasses[] = "class-public";
const char Settings::SafeChecks::XmlExternalFunctions[] = "external-functions"; const char Settings::SafeChecks::XmlExternalFunctions[] = "external-functions";
const char Settings::SafeChecks::XmlInternalFunctions[] = "internal-functions"; const char Settings::SafeChecks::XmlInternalFunctions[] = "internal-functions";
const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables"; const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables";
Settings::Settings() : maxCtuDepth(10), maxTemplateRecursion(100) {} Settings::Settings() : maxCtuDepth(10) {}
cppcheck::Platform::Platform() {} cppcheck::Platform::Platform() {}
Library::Library() {}
ImportProject::ImportProject() {} ImportProject::ImportProject() {}
bool ImportProject::sourceFileExists(const std::string & /*file*/) { bool ImportProject::sourceFileExists(const std::string & /*file*/) {
return true; return true;

View File

@ -36,11 +36,7 @@
#include <QVariant> #include <QVariant>
ThreadHandler::ThreadHandler(QObject *parent) : ThreadHandler::ThreadHandler(QObject *parent) :
QObject(parent), QObject(parent)
mScanDuration(0),
mRunningThreadCount(0),
mAnalyseWholeProgram(false)
{ {
setThreadCount(1); setThreadCount(1);
} }

View File

@ -230,7 +230,7 @@ protected:
* @brief The previous scan duration in milliseconds. * @brief The previous scan duration in milliseconds.
* *
*/ */
int mScanDuration; int mScanDuration{};
/** /**
* @brief Function to delete all threads * @brief Function to delete all threads
@ -254,9 +254,9 @@ protected:
* @brief The amount of threads currently running * @brief The amount of threads currently running
* *
*/ */
int mRunningThreadCount; int mRunningThreadCount{};
bool mAnalyseWholeProgram; bool mAnalyseWholeProgram{};
QStringList mAddonsAndTools; QStringList mAddonsAndTools;
QList<Suppressions::Suppression> mSuppressions; QList<Suppressions::Suppression> mSuppressions;

View File

@ -28,11 +28,6 @@
#include <QFile> #include <QFile>
#include <QMutexLocker> #include <QMutexLocker>
ThreadResult::ThreadResult() : QObject(), ErrorLogger(), mMaxProgress(0), mProgress(0), mFilesChecked(0), mTotalFiles(0)
{
//ctor
}
ThreadResult::~ThreadResult() ThreadResult::~ThreadResult()
{ {
//dtor //dtor

View File

@ -45,7 +45,7 @@ class ErrorItem;
class ThreadResult : public QObject, public ErrorLogger { class ThreadResult : public QObject, public ErrorLogger {
Q_OBJECT Q_OBJECT
public: public:
ThreadResult(); ThreadResult() = default;
~ThreadResult() override; ~ThreadResult() override;
/** /**
@ -142,25 +142,25 @@ protected:
* @brief Max progress * @brief Max progress
* *
*/ */
quint64 mMaxProgress; quint64 mMaxProgress{};
/** /**
* @brief Current progress * @brief Current progress
* *
*/ */
quint64 mProgress; quint64 mProgress{};
/** /**
* @brief Current number of files checked * @brief Current number of files checked
* *
*/ */
unsigned long mFilesChecked; unsigned long mFilesChecked{};
/** /**
* @brief Total number of files * @brief Total number of files
* *
*/ */
unsigned long mTotalFiles; unsigned long mTotalFiles{};
}; };
/// @} /// @}
#endif // THREADRESULT_H #endif // THREADRESULT_H

View File

@ -42,8 +42,7 @@ static UNUSED void unused()
TranslationHandler::TranslationHandler(QObject *parent) : TranslationHandler::TranslationHandler(QObject *parent) :
QObject(parent), QObject(parent),
mCurrentLanguage("en"), mCurrentLanguage("en")
mTranslator(nullptr)
{ {
// Add our available languages // Add our available languages
// Keep this list sorted // Keep this list sorted

View File

@ -135,7 +135,7 @@ private:
* @brief Translator class instance. * @brief Translator class instance.
* *
*/ */
QTranslator *mTranslator; QTranslator* mTranslator{};
}; };
/// @} /// @}

View File

@ -32,7 +32,7 @@ class ValuePtr;
struct Analyzer { struct Analyzer {
struct Action { struct Action {
Action() : mFlag(0) {} Action() = default;
template<class T, template<class T,
REQUIRES("T must be convertible to unsigned int", std::is_convertible<T, unsigned int> ), REQUIRES("T must be convertible to unsigned int", std::is_convertible<T, unsigned int> ),
@ -125,7 +125,7 @@ struct Analyzer {
} }
private: private:
unsigned int mFlag; unsigned int mFlag{};
}; };
enum class Terminate { None, Bail, Escape, Modified, Inconclusive, Conditional }; enum class Terminate { None, Bail, Escape, Modified, Inconclusive, Conditional };

View File

@ -35,7 +35,7 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
Check::Check(const std::string &aname) Check::Check(const std::string &aname)
: mTokenizer(nullptr), mSettings(nullptr), mErrorLogger(nullptr), mName(aname) : mName(aname)
{ {
{ {
const auto it = std::find_if(instances().begin(), instances().end(), [&](const Check *i) { const auto it = std::find_if(instances().begin(), instances().end(), [&](const Check *i) {

View File

@ -130,9 +130,9 @@ public:
static std::string getMessageId(const ValueFlow::Value &value, const char id[]); static std::string getMessageId(const ValueFlow::Value &value, const char id[]);
protected: protected:
const Tokenizer * const mTokenizer; const Tokenizer* const mTokenizer{};
const Settings * const mSettings; const Settings* const mSettings{};
ErrorLogger * const mErrorLogger; ErrorLogger* const mErrorLogger{};
/** report an error */ /** report an error */
void reportError(const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg) { void reportError(const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg) {

View File

@ -53,7 +53,7 @@ namespace tinyxml2 {
class CPPCHECKLIB CheckClass : public Check { class CPPCHECKLIB CheckClass : public Check {
public: public:
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckClass() : Check(myName()), mSymbolDatabase(nullptr) {} CheckClass() : Check(myName()) {}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger); CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
@ -195,7 +195,7 @@ public:
static const std::set<std::string> stl_containers_not_const; static const std::set<std::string> stl_containers_not_const;
private: private:
const SymbolDatabase *mSymbolDatabase; const SymbolDatabase* mSymbolDatabase{};
// Reporting errors.. // Reporting errors..
void noConstructorError(const Token *tok, const std::string &classname, bool isStruct); void noConstructorError(const Token *tok, const std::string &classname, bool isStruct);
@ -330,16 +330,16 @@ private:
// constructors helper function // constructors helper function
/** @brief Information about a member variable. Used when checking for uninitialized variables */ /** @brief Information about a member variable. Used when checking for uninitialized variables */
struct Usage { struct Usage {
explicit Usage(const Variable *var) : var(var), assign(false), init(false) {} explicit Usage(const Variable *var) : var(var) {}
/** Variable that this usage is for */ /** Variable that this usage is for */
const Variable *var; const Variable *var;
/** @brief has this variable been assigned? */ /** @brief has this variable been assigned? */
bool assign; bool assign{};
/** @brief has this variable been initialized? */ /** @brief has this variable been initialized? */
bool init; bool init{};
}; };
static bool isBaseClassMutableMemberFunc(const Token *tok, const Scope *scope); static bool isBaseClassMutableMemberFunc(const Token *tok, const Scope *scope);

View File

@ -106,14 +106,14 @@ static OpenMode getMode(const std::string& str)
struct Filepointer { struct Filepointer {
OpenMode mode; OpenMode mode;
nonneg int mode_indent; nonneg int mode_indent{};
enum class Operation {NONE, UNIMPORTANT, READ, WRITE, POSITIONING, OPEN, CLOSE, UNKNOWN_OP} lastOperation; enum class Operation {NONE, UNIMPORTANT, READ, WRITE, POSITIONING, OPEN, CLOSE, UNKNOWN_OP} lastOperation = Operation::NONE;
nonneg int op_indent; nonneg int op_indent{};
enum class AppendMode { UNKNOWN_AM, APPEND, APPEND_EX }; enum class AppendMode { UNKNOWN_AM, APPEND, APPEND_EX };
AppendMode append_mode; AppendMode append_mode = AppendMode::UNKNOWN_AM;
std::string filename; std::string filename;
explicit Filepointer(OpenMode mode_ = OpenMode::UNKNOWN_OM) explicit Filepointer(OpenMode mode_ = OpenMode::UNKNOWN_OM)
: mode(mode_), mode_indent(0), lastOperation(Operation::NONE), op_indent(0), append_mode(AppendMode::UNKNOWN_AM) {} : mode(mode_) {}
}; };
namespace { namespace {
@ -1331,14 +1331,7 @@ void CheckIO::checkFormatString(const Token * const tok,
/// @todo add non-string literals, and generic expressions /// @todo add non-string literals, and generic expressions
CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings, bool _isCPP) CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings, bool _isCPP)
: variableInfo(nullptr) : isCPP(_isCPP)
, typeToken(nullptr)
, functionInfo(nullptr)
, tempToken(nullptr)
, element(false)
, _template(false)
, address(false)
, isCPP(_isCPP)
{ {
if (!arg) if (!arg)
return; return;

View File

@ -86,14 +86,14 @@ private:
bool isStdContainer(const Token *tok); bool isStdContainer(const Token *tok);
bool isLibraryType(const Settings *settings) const; bool isLibraryType(const Settings *settings) const;
const Variable *variableInfo; const Variable* variableInfo{};
const Token *typeToken; const Token* typeToken{};
const Function *functionInfo; const Function* functionInfo{};
Token *tempToken; Token* tempToken{};
bool element; bool element{};
bool _template; bool _template{};
bool address; bool address{};
bool isCPP; bool isCPP{};
}; };
void checkFormatString(const Token * const tok, void checkFormatString(const Token * const tok,

View File

@ -48,9 +48,9 @@ namespace tinyxml2 {
struct VariableValue { struct VariableValue {
explicit VariableValue(MathLib::bigint val = 0) : value(val), notEqual(false) {} explicit VariableValue(MathLib::bigint val = 0) : value(val) {}
MathLib::bigint value; MathLib::bigint value;
bool notEqual; bool notEqual{};
}; };
/// @addtogroup Checks /// @addtogroup Checks

View File

@ -101,14 +101,11 @@ private:
return "Check for functions that are never called\n"; return "Check for functions that are never called\n";
} }
class CPPCHECKLIB FunctionUsage { struct CPPCHECKLIB FunctionUsage {
public:
FunctionUsage() : lineNumber(0), usedSameFile(false), usedOtherFile(false) {}
std::string filename; std::string filename;
unsigned int lineNumber; unsigned int lineNumber{};
bool usedSameFile; bool usedSameFile{};
bool usedOtherFile; bool usedOtherFile{};
}; };
std::unordered_map<std::string, FunctionUsage> mFunctions; std::unordered_map<std::string, FunctionUsage> mFunctions;

View File

@ -635,7 +635,7 @@ static bool isPartOfClassStructUnion(const Token* tok)
if (tok->str() == "}" || tok->str() == ")") if (tok->str() == "}" || tok->str() == ")")
tok = tok->link(); tok = tok->link();
else if (tok->str() == "(") else if (tok->str() == "(")
return (false); return false;
else if (tok->str() == "{") { else if (tok->str() == "{") {
return (tok->strAt(-1) == "struct" || tok->strAt(-2) == "struct" || tok->strAt(-1) == "class" || tok->strAt(-2) == "class" || tok->strAt(-1) == "union" || tok->strAt(-2) == "union"); return (tok->strAt(-1) == "struct" || tok->strAt(-2) == "struct" || tok->strAt(-1) == "class" || tok->strAt(-2) == "class" || tok->strAt(-1) == "union" || tok->strAt(-2) == "union");
} }

View File

@ -205,10 +205,10 @@ static std::vector<std::string> splitString(const std::string &line)
namespace clangimport { namespace clangimport {
struct Data { struct Data {
struct Decl { struct Decl {
explicit Decl(Scope *scope) : def(nullptr), enumerator(nullptr), function(nullptr), scope(scope), var(nullptr) {} explicit Decl(Scope *scope) : scope(scope) {}
Decl(Token *def, Variable *var) : def(def), enumerator(nullptr), function(nullptr), scope(nullptr), var(var) {} Decl(Token *def, Variable *var) : def(def), var(var) {}
Decl(Token *def, Function *function) : def(def), enumerator(nullptr), function(function), scope(nullptr), var(nullptr) {} Decl(Token *def, Function *function) : def(def), function(function) {}
Decl(Token *def, Enumerator *enumerator) : def(def), enumerator(enumerator), function(nullptr), scope(nullptr), var(nullptr) {} Decl(Token *def, Enumerator *enumerator) : def(def), enumerator(enumerator) {}
void ref(Token *tok) const { void ref(Token *tok) const {
if (enumerator) if (enumerator)
tok->enumerator(enumerator); tok->enumerator(enumerator);
@ -219,11 +219,11 @@ namespace clangimport {
tok->varId(var->declarationId()); tok->varId(var->declarationId());
} }
} }
Token *def; Token* def{};
Enumerator *enumerator; Enumerator* enumerator{};
Function *function; Function* function{};
Scope *scope; Scope* scope{};
Variable *var; Variable* var{};
}; };
const Settings *mSettings = nullptr; const Settings *mSettings = nullptr;

View File

@ -391,10 +391,7 @@ CppCheck::CppCheck(ErrorLogger &errorLogger,
bool useGlobalSuppressions, bool useGlobalSuppressions,
std::function<bool(std::string,std::vector<std::string>,std::string,std::string&)> executeCommand) std::function<bool(std::string,std::vector<std::string>,std::string,std::string&)> executeCommand)
: mErrorLogger(errorLogger) : mErrorLogger(errorLogger)
, mExitCode(0)
, mUseGlobalSuppressions(useGlobalSuppressions) , mUseGlobalSuppressions(useGlobalSuppressions)
, mTooManyConfigs(false)
, mSimplify(true)
, mExecuteCommand(std::move(executeCommand)) , mExecuteCommand(std::move(executeCommand))
{} {}

View File

@ -217,15 +217,15 @@ private:
/** @brief Current preprocessor configuration */ /** @brief Current preprocessor configuration */
std::string mCurrentConfig; std::string mCurrentConfig;
unsigned int mExitCode; unsigned int mExitCode{};
bool mUseGlobalSuppressions; bool mUseGlobalSuppressions;
/** Are there too many configs? */ /** Are there too many configs? */
bool mTooManyConfigs; bool mTooManyConfigs{};
/** Simplify code? true by default */ /** Simplify code? true by default */
bool mSimplify; bool mSimplify = true;
/** File info used for whole program analysis */ /** File info used for whole program analysis */
std::list<Check::FileInfo*> mFileInfo; std::list<Check::FileInfo*> mFileInfo;

View File

@ -158,7 +158,6 @@ std::string CTU::toString(const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsa
CTU::FileInfo::CallBase::CallBase(const Tokenizer *tokenizer, const Token *callToken) CTU::FileInfo::CallBase::CallBase(const Tokenizer *tokenizer, const Token *callToken)
: callId(getFunctionId(tokenizer, callToken->function())) : callId(getFunctionId(tokenizer, callToken->function()))
, callArgNr(0)
, callFunctionName(callToken->next()->astOperand1()->expressionString()) , callFunctionName(callToken->next()->astOperand1()->expressionString())
, location(CTU::FileInfo::Location(tokenizer, callToken)) , location(CTU::FileInfo::Location(tokenizer, callToken))
{} {}
@ -166,7 +165,6 @@ CTU::FileInfo::CallBase::CallBase(const Tokenizer *tokenizer, const Token *callT
CTU::FileInfo::NestedCall::NestedCall(const Tokenizer *tokenizer, const Function *myFunction, const Token *callToken) CTU::FileInfo::NestedCall::NestedCall(const Tokenizer *tokenizer, const Function *myFunction, const Token *callToken)
: CallBase(tokenizer, callToken) : CallBase(tokenizer, callToken)
, myId(getFunctionId(tokenizer, myFunction)) , myId(getFunctionId(tokenizer, myFunction))
, myArgNr(0)
{} {}
static std::string readAttrString(const tinyxml2::XMLElement *e, const char *attr, bool *error) static std::string readAttrString(const tinyxml2::XMLElement *e, const char *attr, bool *error)

View File

@ -51,15 +51,15 @@ struct ForwardTraversal {
enum class Progress { Continue, Break, Skip }; enum class Progress { Continue, Break, Skip };
enum class Terminate { None, Bail, Inconclusive }; enum class Terminate { None, Bail, Inconclusive };
ForwardTraversal(const ValuePtr<Analyzer>& analyzer, const Settings& settings) ForwardTraversal(const ValuePtr<Analyzer>& analyzer, const Settings& settings)
: analyzer(analyzer), settings(settings), actions(Analyzer::Action::None), analyzeOnly(false), analyzeTerminate(false) : analyzer(analyzer), settings(settings)
{} {}
ValuePtr<Analyzer> analyzer; ValuePtr<Analyzer> analyzer;
const Settings& settings; const Settings& settings;
Analyzer::Action actions; Analyzer::Action actions;
bool analyzeOnly; bool analyzeOnly{};
bool analyzeTerminate; bool analyzeTerminate{};
Analyzer::Terminate terminate = Analyzer::Terminate::None; Analyzer::Terminate terminate = Analyzer::Terminate::None;
std::vector<Token*> loopEnds = {}; std::vector<Token*> loopEnds;
Progress Break(Analyzer::Terminate t = Analyzer::Terminate::None) { Progress Break(Analyzer::Terminate t = Analyzer::Terminate::None) {
if ((!analyzeOnly || analyzeTerminate) && t != Analyzer::Terminate::None) if ((!analyzeOnly || analyzeTerminate) && t != Analyzer::Terminate::None)

View File

@ -37,7 +37,7 @@ class Library;
*/ */
class FwdAnalysis { class FwdAnalysis {
public: public:
FwdAnalysis(bool cpp, const Library &library) : mCpp(cpp), mLibrary(library), mWhat(What::Reassign), mValueFlowKnown(true) {} FwdAnalysis(bool cpp, const Library &library) : mCpp(cpp), mLibrary(library) {}
bool hasOperand(const Token *tok, const Token *lhs) const; bool hasOperand(const Token *tok, const Token *lhs) const;
@ -60,8 +60,8 @@ public:
bool unusedValue(const Token *expr, const Token *startToken, const Token *endToken); bool unusedValue(const Token *expr, const Token *startToken, const Token *endToken);
struct KnownAndToken { struct KnownAndToken {
bool known; bool known{};
const Token *token; const Token* token{};
}; };
/** Is there some possible alias for given expression */ /** Is there some possible alias for given expression */
@ -74,9 +74,9 @@ private:
/** Result of forward analysis */ /** Result of forward analysis */
struct Result { struct Result {
enum class Type { NONE, READ, WRITE, BREAK, RETURN, BAILOUT } type; enum class Type { NONE, READ, WRITE, BREAK, RETURN, BAILOUT } type;
explicit Result(Type type) : type(type), token(nullptr) {} explicit Result(Type type) : type(type) {}
Result(Type type, const Token *token) : type(type), token(token) {} Result(Type type, const Token *token) : type(type), token(token) {}
const Token *token; const Token* token{};
}; };
struct Result check(const Token *expr, const Token *startToken, const Token *endToken); struct Result check(const Token *expr, const Token *startToken, const Token *endToken);
@ -87,9 +87,9 @@ private:
const bool mCpp; const bool mCpp;
const Library &mLibrary; const Library &mLibrary;
enum class What { Reassign, UnusedValue, ValueFlow } mWhat; enum class What { Reassign, UnusedValue, ValueFlow } mWhat = What::Reassign;
std::vector<KnownAndToken> mValueFlow; std::vector<KnownAndToken> mValueFlow;
bool mValueFlowKnown; bool mValueFlowKnown = true;
}; };
#endif // fwdanalysisH #endif // fwdanalysisH

View File

@ -502,7 +502,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const
namespace { namespace {
struct ProjectConfiguration { struct ProjectConfiguration {
explicit ProjectConfiguration(const tinyxml2::XMLElement *cfg) : platform(Unknown) { explicit ProjectConfiguration(const tinyxml2::XMLElement *cfg) {
const char *a = cfg->Attribute("Include"); const char *a = cfg->Attribute("Include");
if (a) if (a)
name = a; name = a;
@ -524,7 +524,7 @@ namespace {
} }
std::string name; std::string name;
std::string configuration; std::string configuration;
enum { Win32, x64, Unknown } platform; enum { Win32, x64, Unknown } platform = Unknown;
std::string platformStr; std::string platformStr;
}; };

View File

@ -63,7 +63,6 @@ public:
/** File settings. Multiple configurations for a file is allowed. */ /** File settings. Multiple configurations for a file is allowed. */
struct CPPCHECKLIB FileSettings { struct CPPCHECKLIB FileSettings {
FileSettings() : platformType(cppcheck::Platform::Type::Unspecified), msc(false), useMfc(false) {}
std::string cfg; std::string cfg;
std::string filename; std::string filename;
std::string defines; std::string defines;
@ -74,9 +73,9 @@ public:
std::list<std::string> includePaths; std::list<std::string> includePaths;
std::list<std::string> systemIncludePaths; std::list<std::string> systemIncludePaths;
std::string standard; std::string standard;
cppcheck::Platform::Type platformType; cppcheck::Platform::Type platformType = cppcheck::Platform::Type::Unspecified;
bool msc; bool msc{};
bool useMfc; bool useMfc{};
void parseCommand(const std::string& command); void parseCommand(const std::string& command);
void setDefines(std::string defs); void setDefines(std::string defs);

View File

@ -64,9 +64,6 @@ static void gettokenlistfromvalid(const std::string& valid, TokenList& tokenList
} }
} }
Library::Library() : mAllocId(0)
{}
Library::Error Library::load(const char exename[], const char path[]) Library::Error Library::load(const char exename[], const char path[])
{ {
if (std::strchr(path,',') != nullptr) { if (std::strchr(path,',') != nullptr) {

View File

@ -58,7 +58,7 @@ class CPPCHECKLIB Library {
friend class TestProcessExecutor; // For testing only friend class TestProcessExecutor; // For testing only
public: public:
Library(); Library() = default;
enum class ErrorCode { OK, FILE_NOT_FOUND, BAD_XML, UNKNOWN_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE_VALUE, UNSUPPORTED_FORMAT, DUPLICATE_PLATFORM_TYPE, PLATFORM_TYPE_REDEFINED }; enum class ErrorCode { OK, FILE_NOT_FOUND, BAD_XML, UNKNOWN_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE_VALUE, UNSUPPORTED_FORMAT, DUPLICATE_PLATFORM_TYPE, PLATFORM_TYPE_REDEFINED };
@ -210,18 +210,7 @@ public:
class Container { class Container {
public: public:
Container() Container() = default;
: type_templateArgNo(-1),
size_templateArgNo(-1),
arrayLike_indexOp(false),
stdStringLike(false),
stdAssociativeLike(false),
opLessAllowed(true),
hasInitializerListConstructor(false),
unstableErase(false),
unstableInsert(false),
view(false)
{}
enum class Action { enum class Action {
RESIZE, RESIZE,
@ -259,17 +248,17 @@ public:
}; };
std::string startPattern, startPattern2, endPattern, itEndPattern; std::string startPattern, startPattern2, endPattern, itEndPattern;
std::map<std::string, Function> functions; std::map<std::string, Function> functions;
int type_templateArgNo; int type_templateArgNo = -1;
std::vector<RangeItemRecordTypeItem> rangeItemRecordType; std::vector<RangeItemRecordTypeItem> rangeItemRecordType;
int size_templateArgNo; int size_templateArgNo = -1;
bool arrayLike_indexOp; bool arrayLike_indexOp{};
bool stdStringLike; bool stdStringLike{};
bool stdAssociativeLike; bool stdAssociativeLike{};
bool opLessAllowed; bool opLessAllowed = true;
bool hasInitializerListConstructor; bool hasInitializerListConstructor{};
bool unstableErase; bool unstableErase{};
bool unstableInsert; bool unstableInsert{};
bool view; bool view{};
Action getAction(const std::string& function) const { Action getAction(const std::string& function) const {
const std::map<std::string, Function>::const_iterator i = functions.find(function); const std::map<std::string, Function>::const_iterator i = functions.find(function);
@ -298,47 +287,31 @@ public:
const Container* detectIterator(const Token* typeStart) const; const Container* detectIterator(const Token* typeStart) const;
const Container* detectContainerOrIterator(const Token* typeStart, bool* isIterator = nullptr, bool withoutStd = false) const; const Container* detectContainerOrIterator(const Token* typeStart, bool* isIterator = nullptr, bool withoutStd = false) const;
class ArgumentChecks { struct ArgumentChecks {
public: bool notbool{};
ArgumentChecks() : bool notnull{};
notbool(false), int notuninit = -1;
notnull(false), bool formatstr{};
notuninit(-1), bool strz{};
formatstr(false), bool optional{};
strz(false), bool variadic{};
optional(false),
variadic(false),
iteratorInfo(),
direction(Direction::DIR_UNKNOWN) {}
bool notbool;
bool notnull;
int notuninit;
bool formatstr;
bool strz;
bool optional;
bool variadic;
std::string valid; std::string valid;
class IteratorInfo { struct IteratorInfo {
public: int container{};
IteratorInfo() : container(0), it(false), first(false), last(false) {} bool it{};
bool first{};
int container; bool last{};
bool it;
bool first;
bool last;
}; };
IteratorInfo iteratorInfo; IteratorInfo iteratorInfo;
class MinSize { struct MinSize {
public:
enum class Type { NONE, STRLEN, ARGVALUE, SIZEOF, MUL, VALUE }; enum class Type { NONE, STRLEN, ARGVALUE, SIZEOF, MUL, VALUE };
MinSize(Type t, int a) : type(t), arg(a), arg2(0), value(0) {} MinSize(Type t, int a) : type(t), arg(a) {}
Type type; Type type;
int arg; int arg;
int arg2; int arg2 = 0;
long long value; long long value = 0;
std::string baseType; std::string baseType;
}; };
std::vector<MinSize> minsizes; std::vector<MinSize> minsizes;
@ -349,36 +322,23 @@ public:
DIR_INOUT, ///< Input to called function, and output to caller. Data is passed by reference or address and is potentially modified. DIR_INOUT, ///< Input to called function, and output to caller. Data is passed by reference or address and is potentially modified.
DIR_UNKNOWN ///< direction not known / specified DIR_UNKNOWN ///< direction not known / specified
}; };
Direction direction; Direction direction = Direction::DIR_UNKNOWN;
}; };
struct Function { struct Function {
std::map<int, ArgumentChecks> argumentChecks; // argument nr => argument data std::map<int, ArgumentChecks> argumentChecks; // argument nr => argument data
bool use; bool use{};
bool leakignore; bool leakignore{};
bool isconst; bool isconst{};
bool ispure; bool ispure{};
UseRetValType useretval; UseRetValType useretval = UseRetValType::NONE;
bool ignore; // ignore functions/macros from a library (gtk, qt etc) bool ignore{}; // ignore functions/macros from a library (gtk, qt etc)
bool formatstr; bool formatstr{};
bool formatstr_scan; bool formatstr_scan{};
bool formatstr_secure; bool formatstr_secure{};
Container::Action containerAction; Container::Action containerAction = Container::Action::NO_ACTION;
Container::Yield containerYield; Container::Yield containerYield = Container::Yield::NO_YIELD;
std::string returnType; std::string returnType;
Function()
: use(false),
leakignore(false),
isconst(false),
ispure(false),
useretval(UseRetValType::NONE),
ignore(false),
formatstr(false),
formatstr_scan(false),
formatstr_secure(false),
containerAction(Container::Action::NO_ACTION),
containerYield(Container::Yield::NO_YIELD)
{}
}; };
const Function *getFunction(const Token *ftok) const; const Function *getFunction(const Token *ftok) const;
@ -505,13 +465,6 @@ public:
} }
struct PlatformType { struct PlatformType {
PlatformType()
: mSigned(false)
, mUnsigned(false)
, mLong(false)
, mPointer(false)
, mPtrPtr(false)
, mConstPtr(false) {}
bool operator == (const PlatformType & type) const { bool operator == (const PlatformType & type) const {
return (mSigned == type.mSigned && return (mSigned == type.mSigned &&
mUnsigned == type.mUnsigned && mUnsigned == type.mUnsigned &&
@ -525,12 +478,12 @@ public:
return !(*this == type); return !(*this == type);
} }
std::string mType; std::string mType;
bool mSigned; bool mSigned{};
bool mUnsigned; bool mUnsigned{};
bool mLong; bool mLong{};
bool mPointer; bool mPointer{};
bool mPtrPtr; bool mPtrPtr{};
bool mConstPtr; bool mConstPtr{};
}; };
struct Platform { struct Platform {
@ -594,7 +547,7 @@ private:
}; };
class CodeBlock { class CodeBlock {
public: public:
CodeBlock() : mOffset(0) {} CodeBlock() = default;
void setStart(const char* s) { void setStart(const char* s) {
mStart = s; mStart = s;
@ -624,11 +577,11 @@ private:
private: private:
std::string mStart; std::string mStart;
std::string mEnd; std::string mEnd;
int mOffset; int mOffset{};
std::set<std::string> mBlocks; std::set<std::string> mBlocks;
}; };
enum class FalseTrueMaybe { False, True, Maybe }; enum class FalseTrueMaybe { False, True, Maybe };
int mAllocId; int mAllocId{};
std::set<std::string> mFiles; std::set<std::string> mFiles;
std::map<std::string, AllocFunc> mAlloc; // allocation functions std::map<std::string, AllocFunc> mAlloc; // allocation functions
std::map<std::string, AllocFunc> mDealloc; // deallocation functions std::map<std::string, AllocFunc> mDealloc; // deallocation functions

View File

@ -37,8 +37,7 @@
const int MathLib::bigint_bits = 64; const int MathLib::bigint_bits = 64;
MathLib::value::value(const std::string &s) : MathLib::value::value(const std::string &s)
mIntValue(0), mDoubleValue(0), mIsUnsigned(false)
{ {
if (MathLib::isFloat(s)) { if (MathLib::isFloat(s)) {
mType = MathLib::value::Type::FLOAT; mType = MathLib::value::Type::FLOAT;

View File

@ -37,10 +37,10 @@ public:
/** @brief value class */ /** @brief value class */
class value { class value {
private: private:
long long mIntValue; long long mIntValue{};
double mDoubleValue; double mDoubleValue{};
enum class Type { INT, LONG, LONGLONG, FLOAT } mType; enum class Type { INT, LONG, LONGLONG, FLOAT } mType;
bool mIsUnsigned; bool mIsUnsigned{};
void promote(const value &v); void promote(const value &v);

View File

@ -429,7 +429,7 @@ static ProgramMemory getInitialProgramState(const Token* tok,
return pm; return pm;
} }
ProgramMemoryState::ProgramMemoryState(const Settings* s) : state(), origins(), settings(s) {} ProgramMemoryState::ProgramMemoryState(const Settings* s) : settings(s) {}
void ProgramMemoryState::insert(const ProgramMemory &pm, const Token* origin) void ProgramMemoryState::insert(const ProgramMemory &pm, const Token* origin)
{ {

View File

@ -36,44 +36,6 @@ const char Settings::SafeChecks::XmlInternalFunctions[] = "internal-functions";
const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables"; const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables";
Settings::Settings() Settings::Settings()
: checkAllConfigurations(true),
checkConfiguration(false),
checkHeaders(true),
checkLibrary(false),
checksMaxTime(0),
checkUnusedTemplates(true),
clang(false),
clangExecutable("clang"),
clangTidy(false),
clearIncludeCache(false),
daca(false),
debugnormal(false),
debugSimplified(false),
debugtemplate(false),
debugwarnings(false),
dump(false),
enforcedLang(Language::None),
exceptionHandling(false),
exitCode(0),
force(false),
inlineSuppressions(false),
jobs(1),
loadAverage(0),
maxConfigs(12),
maxCtuDepth(2),
maxTemplateRecursion(100),
performanceValueFlowMaxTime(-1),
preprocessOnly(false),
quiet(false),
relativePaths(false),
reportProgress(false),
showtime(SHOWTIME_MODES::SHOWTIME_NONE),
templateMaxTime(0),
typedefMaxTime(0),
valueFlowMaxIterations(4),
verbose(false),
xml(false),
xml_version(2)
{ {
severity.setEnabled(Severity::error, true); severity.setEnabled(Severity::error, true);
certainty.setEnabled(Certainty::normal, true); certainty.setEnabled(Certainty::normal, true);

View File

@ -114,39 +114,39 @@ public:
std::string buildDir; std::string buildDir;
/** @brief check all configurations (false if -D or --max-configs is used */ /** @brief check all configurations (false if -D or --max-configs is used */
bool checkAllConfigurations; bool checkAllConfigurations = true;
/** Is the 'configuration checking' wanted? */ /** Is the 'configuration checking' wanted? */
bool checkConfiguration; bool checkConfiguration{};
/** /**
* Check code in the headers, this is on by default but can * Check code in the headers, this is on by default but can
* be turned off to save CPU */ * be turned off to save CPU */
bool checkHeaders; bool checkHeaders = true;
/** Check for incomplete info in library files? */ /** Check for incomplete info in library files? */
bool checkLibrary; bool checkLibrary{};
/** @brief The maximum time in seconds for the checks of a single file */ /** @brief The maximum time in seconds for the checks of a single file */
int checksMaxTime; int checksMaxTime{};
/** @brief check unknown function return values */ /** @brief check unknown function return values */
std::set<std::string> checkUnknownFunctionReturn; std::set<std::string> checkUnknownFunctionReturn;
/** Check unused/uninstantiated templates */ /** Check unused/uninstantiated templates */
bool checkUnusedTemplates; bool checkUnusedTemplates = true;
/** Use Clang */ /** Use Clang */
bool clang; bool clang{};
/** Custom Clang executable */ /** Custom Clang executable */
std::string clangExecutable; std::string clangExecutable = "clang";
/** Use clang-tidy */ /** Use clang-tidy */
bool clangTidy; bool clangTidy{};
/** Internal: Clear the simplecpp non-existing include cache */ /** Internal: Clear the simplecpp non-existing include cache */
bool clearIncludeCache; bool clearIncludeCache{};
/** @brief include paths excluded from checking the configuration */ /** @brief include paths excluded from checking the configuration */
std::set<std::string> configExcludePaths; std::set<std::string> configExcludePaths;
@ -158,22 +158,22 @@ public:
std::string cppcheckCfgAbout; std::string cppcheckCfgAbout;
/** @brief Are we running from DACA script? */ /** @brief Are we running from DACA script? */
bool daca; bool daca{};
/** @brief Is --debug-normal given? */ /** @brief Is --debug-normal given? */
bool debugnormal; bool debugnormal{};
/** @brief Is --debug-simplified given? */ /** @brief Is --debug-simplified given? */
bool debugSimplified; bool debugSimplified{};
/** @brief Is --debug-template given? */ /** @brief Is --debug-template given? */
bool debugtemplate; bool debugtemplate{};
/** @brief Is --debug-warnings given? */ /** @brief Is --debug-warnings given? */
bool debugwarnings; bool debugwarnings{};
/** @brief Is --dump given? */ /** @brief Is --dump given? */
bool dump; bool dump{};
std::string dumpFile; std::string dumpFile;
enum Language { enum Language {
@ -181,34 +181,34 @@ public:
}; };
/** @brief Name of the language that is enforced. Empty per default. */ /** @brief Name of the language that is enforced. Empty per default. */
Language enforcedLang; Language enforcedLang{};
/** @brief Is --exception-handling given */ /** @brief Is --exception-handling given */
bool exceptionHandling; bool exceptionHandling{};
// argv[0] // argv[0]
std::string exename; std::string exename;
/** @brief If errors are found, this value is returned from main(). /** @brief If errors are found, this value is returned from main().
Default value is 0. */ Default value is 0. */
int exitCode; int exitCode{};
/** @brief List of --file-filter for analyzing special files */ /** @brief List of --file-filter for analyzing special files */
std::vector<std::string> fileFilters; std::vector<std::string> fileFilters;
/** @brief Force checking the files with "too many" configurations (--force). */ /** @brief Force checking the files with "too many" configurations (--force). */
bool force; bool force{};
/** @brief List of include paths, e.g. "my/includes/" which should be used /** @brief List of include paths, e.g. "my/includes/" which should be used
for finding include files inside source files. (-I) */ for finding include files inside source files. (-I) */
std::list<std::string> includePaths; std::list<std::string> includePaths;
/** @brief Is --inline-suppr given? */ /** @brief Is --inline-suppr given? */
bool inlineSuppressions; bool inlineSuppressions{};
/** @brief How many processes/threads should do checking at the same /** @brief How many processes/threads should do checking at the same
time. Default is 1. (-j N) */ time. Default is 1. (-j N) */
unsigned int jobs; unsigned int jobs = 1;
/** @brief --library= */ /** @brief --library= */
std::list<std::string> libraries; std::list<std::string> libraries;
@ -217,17 +217,17 @@ public:
Library library; Library library;
/** @brief Load average value */ /** @brief Load average value */
int loadAverage; int loadAverage{};
/** @brief Maximum number of configurations to check before bailing. /** @brief Maximum number of configurations to check before bailing.
Default is 12. (--max-configs=N) */ Default is 12. (--max-configs=N) */
int maxConfigs; int maxConfigs = 12;
/** @brief --max-ctu-depth */ /** @brief --max-ctu-depth */
int maxCtuDepth; int maxCtuDepth = 2;
/** @brief max template recursion */ /** @brief max template recursion */
int maxTemplateRecursion; int maxTemplateRecursion = 100;
/** @brief suppress exitcode */ /** @brief suppress exitcode */
Suppressions nofail; Suppressions nofail;
@ -241,7 +241,7 @@ public:
cppcheck::Platform platform; cppcheck::Platform platform;
/** @brief Experimental: --performance-valueflow-max-time=T */ /** @brief Experimental: --performance-valueflow-max-time=T */
int performanceValueFlowMaxTime; int performanceValueFlowMaxTime = -1;
/** @brief --performance-valueflow-max-if-count=C */ /** @brief --performance-valueflow-max-if-count=C */
int performanceValueFlowMaxIfCount; int performanceValueFlowMaxIfCount;
@ -256,33 +256,26 @@ public:
std::string premiumArgs; std::string premiumArgs;
/** @brief Using -E for debugging purposes */ /** @brief Using -E for debugging purposes */
bool preprocessOnly; bool preprocessOnly{};
ImportProject project; ImportProject project;
/** @brief Is --quiet given? */ /** @brief Is --quiet given? */
bool quiet; bool quiet{};
/** @brief Use relative paths in output. */ /** @brief Use relative paths in output. */
bool relativePaths; bool relativePaths{};
/** @brief --report-progress */ /** @brief --report-progress */
bool reportProgress; bool reportProgress{};
/** Rule */ /** Rule */
class CPPCHECKLIB Rule { struct CPPCHECKLIB Rule {
public: std::string tokenlist = "normal"; // use normal tokenlist
Rule()
: tokenlist("normal") // use normal tokenlist
, id("rule") // default id
, severity(Severity::style) { // default severity
}
std::string tokenlist;
std::string pattern; std::string pattern;
std::string id; std::string id = "rule"; // default id
std::string summary; std::string summary;
Severity::SeverityType severity; Severity::SeverityType severity = Severity::style; // default severity
}; };
#ifdef HAVE_RULES #ifdef HAVE_RULES
@ -293,9 +286,7 @@ public:
#endif #endif
/** Do not only check how interface is used. Also check that interface is safe. */ /** Do not only check how interface is used. Also check that interface is safe. */
class CPPCHECKLIB SafeChecks { struct CPPCHECKLIB SafeChecks {
public:
SafeChecks() : classes(false), externalFunctions(false), internalFunctions(false), externalVariables(false) {}
static const char XmlRootName[]; static const char XmlRootName[];
static const char XmlClasses[]; static const char XmlClasses[];
@ -313,26 +304,26 @@ public:
* - public functions can be called in any order * - public functions can be called in any order
* - public variables can have any value * - public variables can have any value
*/ */
bool classes; bool classes{};
/** /**
* External functions * External functions
* - external functions can be called in any order * - external functions can be called in any order
* - function parameters can have any values * - function parameters can have any values
*/ */
bool externalFunctions; bool externalFunctions{};
/** /**
* Experimental: assume that internal functions can be used in any way * Experimental: assume that internal functions can be used in any way
* This is only available in the GUI. * This is only available in the GUI.
*/ */
bool internalFunctions; bool internalFunctions{};
/** /**
* Global variables that can be modified outside the TU. * Global variables that can be modified outside the TU.
* - Such variable can have "any" value * - Such variable can have "any" value
*/ */
bool externalVariables; bool externalVariables{};
}; };
SafeChecks safeChecks; SafeChecks safeChecks;
@ -342,7 +333,7 @@ public:
SimpleEnableGroup<Checks> checks; SimpleEnableGroup<Checks> checks;
/** @brief show timing information (--showtime=file|summary|top5) */ /** @brief show timing information (--showtime=file|summary|top5) */
SHOWTIME_MODES showtime; SHOWTIME_MODES showtime{};
/** Struct contains standards settings */ /** Struct contains standards settings */
Standards standards; Standards standards;
@ -356,10 +347,10 @@ public:
std::string templateLocation; std::string templateLocation;
/** @brief The maximum time in seconds for the template instantiation */ /** @brief The maximum time in seconds for the template instantiation */
std::size_t templateMaxTime; std::size_t templateMaxTime{};
/** @brief The maximum time in seconds for the typedef simplification */ /** @brief The maximum time in seconds for the typedef simplification */
std::size_t typedefMaxTime; std::size_t typedefMaxTime{};
/** @brief defines given by the user */ /** @brief defines given by the user */
std::string userDefines; std::string userDefines;
@ -371,16 +362,16 @@ public:
std::list<std::string> userIncludes; std::list<std::string> userIncludes;
/** @brief the maximum iterations of valueflow (--valueflow-max-iterations=T) */ /** @brief the maximum iterations of valueflow (--valueflow-max-iterations=T) */
std::size_t valueFlowMaxIterations; std::size_t valueFlowMaxIterations = 4;
/** @brief Is --verbose given? */ /** @brief Is --verbose given? */
bool verbose; bool verbose{};
/** @brief write XML results (--xml) */ /** @brief write XML results (--xml) */
bool xml; bool xml{};
/** @brief XML version (--xml-version=..) */ /** @brief XML version (--xml-version=..) */
int xml_version; int xml_version = 2;
/** /**
* @brief return true if a included file is to be excluded in Preprocessor::getConfigs * @brief return true if a included file is to be excluded in Preprocessor::getConfigs

View File

@ -35,17 +35,14 @@
*/ */
struct Standards { struct Standards {
/** C code standard */ /** C code standard */
enum cstd_t { C89, C99, C11, CLatest=C11 } c; enum cstd_t { C89, C99, C11, CLatest = C11 } c = CLatest;
/** C++ code standard */ /** C++ code standard */
enum cppstd_t { CPP03, CPP11, CPP14, CPP17, CPP20, CPP23, CPPLatest=CPP23 } cpp; enum cppstd_t { CPP03, CPP11, CPP14, CPP17, CPP20, CPP23, CPPLatest = CPP23 } cpp = CPPLatest;
/** --std value given on command line */ /** --std value given on command line */
std::string stdValue; std::string stdValue;
/** This constructor clear all the variables **/
Standards() : c(CLatest), cpp(CPPLatest) {}
bool setC(const std::string& str) { bool setC(const std::string& str) {
stdValue = str; stdValue = str;
if (str == "c89" || str == "C89") { if (str == "c89" || str == "C89") {

View File

@ -55,8 +55,8 @@ public:
}; };
struct CPPCHECKLIB Suppression { struct CPPCHECKLIB Suppression {
Suppression() : lineNumber(NO_LINE), hash(0), thisAndNextLine(false), matched(false), checked(false) {} Suppression() = default;
Suppression(std::string id, std::string file, int line=NO_LINE) : errorId(std::move(id)), fileName(std::move(file)), lineNumber(line), hash(0), thisAndNextLine(false), matched(false), checked(false) {} Suppression(std::string id, std::string file, int line=NO_LINE) : errorId(std::move(id)), fileName(std::move(file)), lineNumber(line) {}
bool operator<(const Suppression &other) const { bool operator<(const Suppression &other) const {
if (errorId != other.errorId) if (errorId != other.errorId)
@ -103,12 +103,12 @@ public:
std::string errorId; std::string errorId;
std::string fileName; std::string fileName;
int lineNumber; int lineNumber = NO_LINE;
std::string symbolName; std::string symbolName;
std::size_t hash; std::size_t hash{};
bool thisAndNextLine; // Special case for backwards compatibility: { // cppcheck-suppress something bool thisAndNextLine{}; // Special case for backwards compatibility: { // cppcheck-suppress something
bool matched; bool matched{};
bool checked; // for inline suppressions, checked or not bool checked{}; // for inline suppressions, checked or not
enum { NO_LINE = -1 }; enum { NO_LINE = -1 };
}; };

View File

@ -2086,8 +2086,7 @@ Variable::Variable(const Token *name_, const std::string &clangType, const Token
mAccess(access_), mAccess(access_),
mFlags(0), mFlags(0),
mType(type_), mType(type_),
mScope(scope_), mScope(scope_)
mValueType(nullptr)
{ {
if (!mTypeStartToken && mTypeEndToken) { if (!mTypeStartToken && mTypeEndToken) {
mTypeStartToken = mTypeEndToken; mTypeStartToken = mTypeEndToken;
@ -2135,14 +2134,12 @@ Variable::Variable(const Token *name_, const std::string &clangType, const Token
} }
Variable::Variable(const Variable &var, const Scope *scope) Variable::Variable(const Variable &var, const Scope *scope)
: mValueType(nullptr)
{ {
*this = var; *this = var;
mScope = scope; mScope = scope;
} }
Variable::Variable(const Variable &var) Variable::Variable(const Variable &var)
: mValueType(nullptr)
{ {
*this = var; *this = var;
} }
@ -2401,20 +2398,7 @@ Function::Function(const Tokenizer *mTokenizer,
const Token *tokArgDef) const Token *tokArgDef)
: tokenDef(tokDef), : tokenDef(tokDef),
argDef(tokArgDef), argDef(tokArgDef),
token(nullptr), nestedIn(scope)
arg(nullptr),
retDef(nullptr),
retType(nullptr),
functionScope(nullptr),
nestedIn(scope),
initArgCount(0),
type(eFunction),
noexceptArg(nullptr),
throwArg(nullptr),
templateDef(nullptr),
functionPointerUsage(nullptr),
access(AccessControl::Public),
mFlags(0)
{ {
// operator function // operator function
if (::isOperator(tokenDef)) { if (::isOperator(tokenDef)) {
@ -2519,22 +2503,7 @@ Function::Function(const Tokenizer *mTokenizer,
} }
Function::Function(const Token *tokenDef, const std::string &clangType) Function::Function(const Token *tokenDef, const std::string &clangType)
: tokenDef(tokenDef), : tokenDef(tokenDef)
argDef(nullptr),
token(nullptr),
arg(nullptr),
retDef(nullptr),
retType(nullptr),
functionScope(nullptr),
nestedIn(nullptr),
initArgCount(0),
type(eFunction),
noexceptArg(nullptr),
throwArg(nullptr),
templateDef(nullptr),
functionPointerUsage(nullptr),
access(AccessControl::Public),
mFlags(0)
{ {
// operator function // operator function
if (::isOperator(tokenDef)) { if (::isOperator(tokenDef)) {
@ -4461,14 +4430,7 @@ Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *
check(check_), check(check_),
classDef(classDef_), classDef(classDef_),
nestedIn(nestedIn_), nestedIn(nestedIn_),
numConstructors(0), type(type_)
numCopyOrMoveConstructors(0),
type(type_),
definedType(nullptr),
functionOf(nullptr),
function(nullptr),
enumType(nullptr),
enumClass(false)
{ {
setBodyStartEnd(start_); setBodyStartEnd(start_);
} }
@ -4476,16 +4438,7 @@ Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *
Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_) : Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_) :
check(check_), check(check_),
classDef(classDef_), classDef(classDef_),
bodyStart(nullptr), nestedIn(nestedIn_)
bodyEnd(nullptr),
nestedIn(nestedIn_),
numConstructors(0),
numCopyOrMoveConstructors(0),
definedType(nullptr),
functionOf(nullptr),
function(nullptr),
enumType(nullptr),
enumClass(false)
{ {
const Token *nameTok = classDef; const Token *nameTok = classDef;
if (!classDef) { if (!classDef) {

View File

@ -60,11 +60,9 @@ enum class AccessControl { Public, Protected, Private, Global, Namespace, Argume
* @brief Array dimension information. * @brief Array dimension information.
*/ */
struct Dimension { struct Dimension {
Dimension() : tok(nullptr), num(0), known(true) {} const Token* tok{}; ///< size token
MathLib::bigint num{}; ///< (assumed) dimension length when size is a number, 0 if not known
const Token *tok; ///< size token bool known = true; ///< Known size
MathLib::bigint num; ///< (assumed) dimension length when size is a number, 0 if not known
bool known; ///< Known size
}; };
/** @brief Information about a class type. */ /** @brief Information about a class type. */
@ -75,18 +73,14 @@ public:
const Scope* enclosingScope; const Scope* enclosingScope;
enum class NeedInitialization { enum class NeedInitialization {
Unknown, True, False Unknown, True, False
} needInitialization; } needInitialization = NeedInitialization::Unknown;
class BaseInfo {
public:
BaseInfo() :
type(nullptr), nameTok(nullptr), access(AccessControl::Public), isVirtual(false) {}
struct BaseInfo {
std::string name; std::string name;
const Type* type; const Type* type{};
const Token* nameTok; const Token* nameTok{};
AccessControl access; // public/protected/private AccessControl access{}; // public/protected/private
bool isVirtual; bool isVirtual{};
// allow ordering within containers // allow ordering within containers
bool operator<(const BaseInfo& rhs) const { bool operator<(const BaseInfo& rhs) const {
return this->type < rhs.type; return this->type < rhs.type;
@ -94,29 +88,22 @@ public:
}; };
struct FriendInfo { struct FriendInfo {
FriendInfo() : const Token* nameStart{};
nameStart(nullptr), nameEnd(nullptr), type(nullptr) {} const Token* nameEnd{};
const Type* type{};
const Token* nameStart;
const Token* nameEnd;
const Type* type;
}; };
std::vector<BaseInfo> derivedFrom; std::vector<BaseInfo> derivedFrom;
std::vector<FriendInfo> friendList; std::vector<FriendInfo> friendList;
const Token * typeStart; const Token* typeStart{};
const Token * typeEnd; const Token* typeEnd{};
MathLib::bigint sizeOf; MathLib::bigint sizeOf{};
explicit Type(const Token* classDef_ = nullptr, const Scope* classScope_ = nullptr, const Scope* enclosingScope_ = nullptr) : explicit Type(const Token* classDef_ = nullptr, const Scope* classScope_ = nullptr, const Scope* enclosingScope_ = nullptr) :
classDef(classDef_), classDef(classDef_),
classScope(classScope_), classScope(classScope_),
enclosingScope(enclosingScope_), enclosingScope(enclosingScope_) {
needInitialization(NeedInitialization::Unknown),
typeStart(nullptr),
typeEnd(nullptr),
sizeOf(0) {
if (classDef_ && classDef_->str() == "enum") if (classDef_ && classDef_->str() == "enum")
needInitialization = NeedInitialization::True; needInitialization = NeedInitialization::True;
else if (classDef_ && classDef_->str() == "using") { else if (classDef_ && classDef_->str() == "using") {
@ -167,15 +154,14 @@ public:
bool isDerivedFrom(const std::string & ancestor) const; bool isDerivedFrom(const std::string & ancestor) const;
}; };
class CPPCHECKLIB Enumerator { struct CPPCHECKLIB Enumerator {
public: explicit Enumerator(const Scope * scope_) : scope(scope_) {}
explicit Enumerator(const Scope * scope_) : scope(scope_), name(nullptr), value(0), start(nullptr), end(nullptr), value_known(false) {}
const Scope * scope; const Scope * scope;
const Token * name; const Token* name{};
MathLib::bigint value; MathLib::bigint value{};
const Token * start; const Token* start{};
const Token * end; const Token* end{};
bool value_known; bool value_known{};
}; };
/** @brief Information about a member variable. */ /** @brief Information about a member variable. */
@ -238,8 +224,7 @@ public:
mAccess(access_), mAccess(access_),
mFlags(0), mFlags(0),
mType(type_), mType(type_),
mScope(scope_), mScope(scope_) {
mValueType(nullptr) {
evaluate(settings); evaluate(settings);
} }
@ -699,7 +684,7 @@ private:
/** @brief pointer to scope this variable is in */ /** @brief pointer to scope this variable is in */
const Scope *mScope; const Scope *mScope;
const ValueType *mValueType; const ValueType* mValueType{};
/** @brief array dimensions */ /** @brief array dimensions */
std::vector<Dimension> mDimensions; std::vector<Dimension> mDimensions;
@ -914,22 +899,22 @@ public:
} }
bool isSafe(const Settings *settings) const; bool isSafe(const Settings *settings) const;
const Token *tokenDef; ///< function name token in class definition const Token* tokenDef{}; ///< function name token in class definition
const Token *argDef; ///< function argument start '(' in class definition const Token* argDef{}; ///< function argument start '(' in class definition
const Token *token; ///< function name token in implementation const Token* token{}; ///< function name token in implementation
const Token *arg; ///< function argument start '(' const Token* arg{}; ///< function argument start '('
const Token *retDef; ///< function return type token const Token* retDef{}; ///< function return type token
const ::Type *retType; ///< function return type const ::Type* retType{}; ///< function return type
const Scope *functionScope; ///< scope of function body const Scope* functionScope{}; ///< scope of function body
const Scope* nestedIn; ///< Scope the function is declared in const Scope* nestedIn{}; ///< Scope the function is declared in
std::vector<Variable> argumentList; ///< argument list std::vector<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 = eFunction; ///< constructor, destructor, ...
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 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;
@ -959,7 +944,7 @@ private:
/** Recursively determine if this function overrides a virtual function in a base class */ /** Recursively determine if this function overrides a virtual function in a base class */
const Function * getOverriddenFunctionRecursive(const ::Type* baseType, bool *foundAllBaseClasses) const; const Function * getOverriddenFunctionRecursive(const ::Type* baseType, bool *foundAllBaseClasses) const;
unsigned int mFlags; unsigned int mFlags{};
void isInline(bool state) { void isInline(bool state) {
setFlag(fIsInline, state); setFlag(fIsInline, state);
@ -1039,31 +1024,31 @@ public:
Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_); Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_);
Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_); Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_);
const SymbolDatabase *check; const SymbolDatabase* check{};
std::string className; std::string className;
const Token *classDef; ///< class/struct/union/namespace token const Token* classDef{}; ///< class/struct/union/namespace token
const Token *bodyStart; ///< '{' token const Token* bodyStart{}; ///< '{' token
const Token *bodyEnd; ///< '}' token const Token* bodyEnd{}; ///< '}' token
std::list<Function> functionList; std::list<Function> functionList;
std::multimap<std::string, const Function *> functionMap; std::multimap<std::string, const Function *> functionMap;
std::list<Variable> varlist; std::list<Variable> varlist;
const Scope *nestedIn; const Scope* nestedIn{};
std::vector<Scope *> nestedList; std::vector<Scope *> nestedList;
nonneg int numConstructors; nonneg int numConstructors{};
nonneg int numCopyOrMoveConstructors; nonneg int numCopyOrMoveConstructors{};
std::vector<UsingInfo> usingList; std::vector<UsingInfo> usingList;
ScopeType type; ScopeType type{};
Type* definedType; Type* definedType{};
std::map<std::string, Type*> definedTypesMap; std::map<std::string, Type*> definedTypesMap;
std::vector<const Token *> bodyStartList; std::vector<const Token *> bodyStartList;
// function specific fields // function specific fields
const Scope *functionOf; ///< scope this function belongs to const Scope* functionOf{}; ///< scope this function belongs to
Function *function; ///< function info for this function Function* function{}; ///< function info for this function
// enum specific fields // enum specific fields
const Token * enumType; const Token* enumType{};
bool enumClass; bool enumClass{};
std::vector<Enumerator> enumeratorList; std::vector<Enumerator> enumeratorList;
@ -1224,7 +1209,7 @@ enum class Reference {
/** Value type */ /** Value type */
class CPPCHECKLIB ValueType { class CPPCHECKLIB ValueType {
public: public:
enum Sign { UNKNOWN_SIGN, SIGNED, UNSIGNED } sign; enum Sign { UNKNOWN_SIGN, SIGNED, UNSIGNED } sign = UNKNOWN_SIGN;
enum Type { enum Type {
UNKNOWN_TYPE, UNKNOWN_TYPE,
POD, POD,
@ -1245,80 +1230,42 @@ public:
FLOAT, FLOAT,
DOUBLE, DOUBLE,
LONGDOUBLE LONGDOUBLE
} type; } type = UNKNOWN_TYPE;
nonneg int bits; ///< bitfield bitcount nonneg int bits{}; ///< bitfield bitcount
nonneg int pointer; ///< 0=>not pointer, 1=>*, 2=>**, 3=>***, etc nonneg int pointer{}; ///< 0=>not pointer, 1=>*, 2=>**, 3=>***, etc
nonneg int constness; ///< bit 0=data, bit 1=*, bit 2=** nonneg int constness{}; ///< bit 0=data, bit 1=*, bit 2=**
Reference reference = Reference::None; ///< Is the outermost indirection of this type a reference or rvalue Reference reference = Reference::None; ///< Is the outermost indirection of this type a reference or rvalue
///< reference or not? pointer=2, Reference=LValue would be a T**& ///< reference or not? pointer=2, Reference=LValue would be a T**&
const Scope* typeScope; ///< if the type definition is seen this point out the type scope const Scope* typeScope{}; ///< if the type definition is seen this point out the type scope
const ::Type* smartPointerType; ///< Smart pointer type const ::Type* smartPointerType{}; ///< Smart pointer type
const Token* smartPointerTypeToken; ///< Smart pointer type token const Token* smartPointerTypeToken{}; ///< Smart pointer type token
const Library::SmartPointer* smartPointer; ///< Smart pointer const Library::SmartPointer* smartPointer{}; ///< Smart pointer
const Library::Container* container; ///< If the type is a container defined in a cfg file, this is the used const Library::Container* container{}; ///< If the type is a container defined in a cfg file, this is the used
///< container ///< container
const Token* containerTypeToken; ///< The container type token. the template argument token that defines the const Token* containerTypeToken{}; ///< The container type token. the template argument token that defines the
///< container element type. ///< container element type.
std::string originalTypeName; ///< original type name as written in the source code. eg. this might be "uint8_t" std::string originalTypeName; ///< original type name as written in the source code. eg. this might be "uint8_t"
///< when type is CHAR. ///< when type is CHAR.
ErrorPath debugPath; ///< debug path to the type ErrorPath debugPath; ///< debug path to the type
ValueType() ValueType() = default;
: sign(UNKNOWN_SIGN),
type(UNKNOWN_TYPE),
bits(0),
pointer(0U),
constness(0U),
typeScope(nullptr),
smartPointerType(nullptr),
smartPointerTypeToken(nullptr),
smartPointer(nullptr),
container(nullptr),
containerTypeToken(nullptr),
debugPath()
{}
ValueType(enum Sign s, enum Type t, nonneg int p) ValueType(enum Sign s, enum Type t, nonneg int p)
: sign(s), : sign(s),
type(t), type(t),
bits(0), pointer(p)
pointer(p),
constness(0U),
typeScope(nullptr),
smartPointerType(nullptr),
smartPointerTypeToken(nullptr),
smartPointer(nullptr),
container(nullptr),
containerTypeToken(nullptr),
debugPath()
{} {}
ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c) ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c)
: sign(s), : sign(s),
type(t), type(t),
bits(0),
pointer(p), pointer(p),
constness(c), constness(c)
typeScope(nullptr),
smartPointerType(nullptr),
smartPointerTypeToken(nullptr),
smartPointer(nullptr),
container(nullptr),
containerTypeToken(nullptr),
debugPath()
{} {}
ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c, std::string otn) ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c, std::string otn)
: sign(s), : sign(s),
type(t), type(t),
bits(0),
pointer(p), pointer(p),
constness(c), constness(c),
typeScope(nullptr), originalTypeName(std::move(otn))
smartPointerType(nullptr),
smartPointerTypeToken(nullptr),
smartPointer(nullptr),
container(nullptr),
containerTypeToken(nullptr),
originalTypeName(std::move(otn)),
debugPath()
{} {}
static ValueType parseDecl(const Token *type, const Settings &settings, bool isCpp); static ValueType parseDecl(const Token *type, const Settings &settings, bool isCpp);

View File

@ -281,7 +281,7 @@ bool TemplateSimplifier::TokenAndName::isAliasToken(const Token *tok) const
TemplateSimplifier::TemplateSimplifier(Tokenizer &tokenizer) TemplateSimplifier::TemplateSimplifier(Tokenizer &tokenizer)
: mTokenizer(tokenizer), mTokenList(mTokenizer.list), mSettings(*mTokenizer.mSettings), : mTokenizer(tokenizer), mTokenList(mTokenizer.list), mSettings(*mTokenizer.mSettings),
mErrorLogger(mTokenizer.mErrorLogger), mChanged(false) mErrorLogger(mTokenizer.mErrorLogger)
{} {}
TemplateSimplifier::~TemplateSimplifier() TemplateSimplifier::~TemplateSimplifier()

View File

@ -500,7 +500,7 @@ private:
TokenList &mTokenList; TokenList &mTokenList;
const Settings &mSettings; const Settings &mSettings;
ErrorLogger *mErrorLogger; ErrorLogger *mErrorLogger;
bool mChanged; bool mChanged{};
std::list<TokenAndName> mTemplateDeclarations; std::list<TokenAndName> mTemplateDeclarations;
std::list<TokenAndName> mTemplateForwardDeclarations; std::list<TokenAndName> mTemplateForwardDeclarations;

View File

@ -101,9 +101,6 @@ Timer::Timer(std::string str, SHOWTIME_MODES showtimeMode, TimerResultsIntf* tim
Timer::Timer(bool fileTotal, std::string filename) Timer::Timer(bool fileTotal, std::string filename)
: mStr(std::move(filename)) : mStr(std::move(filename))
, mTimerResults(nullptr)
, mStart(std::clock())
, mShowTimeMode(SHOWTIME_MODES::SHOWTIME_FILE_TOTAL)
, mStopped(!fileTotal) , mStopped(!fileTotal)
{} {}

View File

@ -43,12 +43,8 @@ public:
}; };
struct TimerResultsData { struct TimerResultsData {
std::clock_t mClocks; std::clock_t mClocks{};
long mNumberOfResults; long mNumberOfResults{};
TimerResultsData()
: mClocks(0)
, mNumberOfResults(0) {}
double seconds() const { double seconds() const {
const double ret = (double)((unsigned long)mClocks) / (double)CLOCKS_PER_SEC; const double ret = (double)((unsigned long)mClocks) / (double)CLOCKS_PER_SEC;
@ -81,10 +77,10 @@ public:
private: private:
const std::string mStr; const std::string mStr;
TimerResultsIntf* mTimerResults; TimerResultsIntf* mTimerResults{};
std::clock_t mStart; std::clock_t mStart = std::clock();
const SHOWTIME_MODES mShowTimeMode; const SHOWTIME_MODES mShowTimeMode = SHOWTIME_MODES::SHOWTIME_FILE_TOTAL;
bool mStopped; bool mStopped{};
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif // timerH #endif // timerH

View File

@ -56,12 +56,7 @@ namespace {
const std::list<ValueFlow::Value> TokenImpl::mEmptyValueList; const std::list<ValueFlow::Value> TokenImpl::mEmptyValueList;
Token::Token(TokensFrontBack *tokensFrontBack) : Token::Token(TokensFrontBack *tokensFrontBack) :
mTokensFrontBack(tokensFrontBack), mTokensFrontBack(tokensFrontBack)
mNext(nullptr),
mPrevious(nullptr),
mLink(nullptr),
mTokType(eNone),
mFlags(0)
{ {
mImpl = new TokenImpl(); mImpl = new TokenImpl();
} }

View File

@ -39,7 +39,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
class Enumerator; struct Enumerator;
class Function; class Function;
class Scope; class Scope;
class Settings; class Settings;
@ -54,48 +54,48 @@ class Token;
* @brief This struct stores pointers to the front and back tokens of the list this token is in. * @brief This struct stores pointers to the front and back tokens of the list this token is in.
*/ */
struct TokensFrontBack { struct TokensFrontBack {
Token *front; Token *front{};
Token *back; Token* back{};
const TokenList* list; const TokenList* list{};
}; };
struct ScopeInfo2 { struct ScopeInfo2 {
ScopeInfo2(std::string name_, const Token *bodyEnd_, std::set<std::string> usingNamespaces_ = std::set<std::string>()) : name(std::move(name_)), bodyEnd(bodyEnd_), usingNamespaces(std::move(usingNamespaces_)) {} ScopeInfo2(std::string name_, const Token *bodyEnd_, std::set<std::string> usingNamespaces_ = std::set<std::string>()) : name(std::move(name_)), bodyEnd(bodyEnd_), usingNamespaces(std::move(usingNamespaces_)) {}
std::string name; std::string name;
const Token * const bodyEnd; const Token* const bodyEnd{};
std::set<std::string> usingNamespaces; std::set<std::string> usingNamespaces;
}; };
enum class TokenDebug { None, ValueFlow, ValueType }; enum class TokenDebug { None, ValueFlow, ValueType };
struct TokenImpl { struct TokenImpl {
nonneg int mVarId; nonneg int mVarId{};
nonneg int mFileIndex; nonneg int mFileIndex{};
nonneg int mLineNumber; nonneg int mLineNumber{};
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 * A value from 0-100 that provides a rough idea about where in the token
* list this token is located. * list this token is located.
*/ */
nonneg int mProgressValue; nonneg int mProgressValue{};
/** /**
* Token index. Position in token list * Token index. Position in token list
*/ */
nonneg int mIndex; nonneg int mIndex{};
/** Bitfield bit count. */ /** Bitfield bit count. */
unsigned char mBits; unsigned char mBits{};
// AST.. // AST..
Token *mAstOperand1; Token* mAstOperand1{};
Token *mAstOperand2; Token* mAstOperand2{};
Token *mAstParent; Token* mAstParent{};
// symbol database information // symbol database information
const Scope *mScope; const Scope* mScope{};
union { union {
const Function *mFunction; const Function *mFunction;
const Variable *mVariable; const Variable *mVariable;
@ -104,60 +104,38 @@ struct TokenImpl {
}; };
// original name like size_t // original name like size_t
std::string* mOriginalName; std::string* mOriginalName{};
// ValueType // ValueType
ValueType *mValueType; ValueType* mValueType{};
// ValueFlow // ValueFlow
std::list<ValueFlow::Value>* mValues; std::list<ValueFlow::Value>* mValues{};
static const std::list<ValueFlow::Value> mEmptyValueList; static const std::list<ValueFlow::Value> mEmptyValueList;
// Pointer to a template in the template simplifier // Pointer to a template in the template simplifier
std::set<TemplateSimplifier::TokenAndName*>* mTemplateSimplifierPointers; std::set<TemplateSimplifier::TokenAndName*>* mTemplateSimplifierPointers{};
// Pointer to the object representing this token's scope // Pointer to the object representing this token's scope
std::shared_ptr<ScopeInfo2> mScopeInfo; std::shared_ptr<ScopeInfo2> mScopeInfo;
// __cppcheck_in_range__ // __cppcheck_in_range__
struct CppcheckAttributes { struct CppcheckAttributes {
enum Type {LOW,HIGH} type; enum Type { LOW, HIGH } type = LOW;
MathLib::bigint value; MathLib::bigint value{};
struct CppcheckAttributes *next; CppcheckAttributes* next{};
}; };
struct CppcheckAttributes *mCppcheckAttributes; CppcheckAttributes* mCppcheckAttributes{};
// 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 = Cpp11init::UNKNOWN;
TokenDebug mDebug; TokenDebug mDebug{};
void setCppcheckAttribute(CppcheckAttributes::Type type, MathLib::bigint value); void setCppcheckAttribute(CppcheckAttributes::Type type, MathLib::bigint value);
bool getCppcheckAttribute(CppcheckAttributes::Type type, MathLib::bigint &value) const; bool getCppcheckAttribute(CppcheckAttributes::Type type, MathLib::bigint &value) const;
TokenImpl() TokenImpl() : mFunction(nullptr) {}
: mVarId(0),
mFileIndex(0),
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
mOriginalName(nullptr),
mValueType(nullptr),
mValues(nullptr),
mTemplateSimplifierPointers(nullptr),
mScopeInfo(nullptr),
mCppcheckAttributes(nullptr),
mCpp11init(Cpp11init::UNKNOWN),
mDebug(TokenDebug::None)
{}
~TokenImpl(); ~TokenImpl();
}; };
@ -177,7 +155,7 @@ struct TokenImpl {
*/ */
class CPPCHECKLIB Token { class CPPCHECKLIB Token {
private: private:
TokensFrontBack* mTokensFrontBack; TokensFrontBack* mTokensFrontBack{};
public: public:
Token(const Token &) = delete; Token(const Token &) = delete;
@ -1301,9 +1279,9 @@ private:
std::string mStr; std::string mStr;
Token *mNext; Token* mNext{};
Token *mPrevious; Token* mPrevious{};
Token *mLink; Token* mLink{};
enum : uint64_t { enum : uint64_t {
fIsUnsigned = (1ULL << 0), fIsUnsigned = (1ULL << 0),
@ -1355,11 +1333,11 @@ private:
efIsUnique = efMaxSize - 2, efIsUnique = efMaxSize - 2,
}; };
Token::Type mTokType; Token::Type mTokType = eNone;
uint64_t mFlags; uint64_t mFlags{};
TokenImpl *mImpl; TokenImpl* mImpl{};
/** /**
* Get specified flag state. * Get specified flag state.

View File

@ -64,15 +64,14 @@ namespace {
// local struct used in setVarId // local struct used in setVarId
// in order to store information about the scope // in order to store information about the scope
struct VarIdScopeInfo { struct VarIdScopeInfo {
VarIdScopeInfo() VarIdScopeInfo() = default;
: isExecutable(false), isStructInit(false), isEnum(false), startVarid(0) {}
VarIdScopeInfo(bool isExecutable, bool isStructInit, bool isEnum, nonneg int startVarid) VarIdScopeInfo(bool isExecutable, bool isStructInit, bool isEnum, nonneg int startVarid)
: isExecutable(isExecutable), isStructInit(isStructInit), isEnum(isEnum), startVarid(startVarid) {} : isExecutable(isExecutable), isStructInit(isStructInit), isEnum(isEnum), startVarid(startVarid) {}
const bool isExecutable; const bool isExecutable{};
const bool isStructInit; const bool isStructInit{};
const bool isEnum; const bool isEnum{};
const nonneg int startVarid; const nonneg int startVarid{};
}; };
} }
@ -162,12 +161,7 @@ Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger, const P
list(settings), list(settings),
mSettings(settings), mSettings(settings),
mErrorLogger(errorLogger), mErrorLogger(errorLogger),
mSymbolDatabase(nullptr),
mTemplateSimplifier(new TemplateSimplifier(*this)), mTemplateSimplifier(new TemplateSimplifier(*this)),
mVarId(0),
mUnnamedCount(0),
mCodeWithTemplates(false), //is there any templates?
mTimerResults(nullptr),
mPreprocessor(preprocessor) mPreprocessor(preprocessor)
{ {
// make sure settings are specified // make sure settings are specified
@ -405,11 +399,10 @@ Token * Tokenizer::deleteInvalidTypedef(Token *typeDef)
namespace { namespace {
struct Space { struct Space {
Space() : bodyEnd(nullptr), bodyEnd2(nullptr), isNamespace(false) {}
std::string className; std::string className;
const Token * bodyEnd; // for body contains typedef define const Token* bodyEnd{}; // for body contains typedef define
const Token * bodyEnd2; // for body contains typedef using const Token* bodyEnd2{}; // for body contains typedef using
bool isNamespace; bool isNamespace{};
std::set<std::string> recordTypes; std::set<std::string> recordTypes;
}; };
} }
@ -4022,9 +4015,9 @@ private:
std::map<std::string, nonneg int> mVariableId; std::map<std::string, nonneg int> mVariableId;
std::map<std::string, nonneg int> mVariableId_global; std::map<std::string, nonneg int> mVariableId_global;
std::stack<std::vector<std::pair<std::string, nonneg int>>> mScopeInfo; std::stack<std::vector<std::pair<std::string, nonneg int>>> mScopeInfo;
mutable nonneg int mVarId; mutable nonneg int mVarId{};
public: public:
VariableMap() : mVarId(0) {} VariableMap() = default;
void enterScope(); void enterScope();
bool leaveScope(); bool leaveScope();
void addVariable(const std::string& varname, bool globalNamespace); void addVariable(const std::string& varname, bool globalNamespace);

View File

@ -698,7 +698,7 @@ private:
ErrorLogger* const mErrorLogger; ErrorLogger* const mErrorLogger;
/** Symbol database that all checks etc can use */ /** Symbol database that all checks etc can use */
SymbolDatabase *mSymbolDatabase; SymbolDatabase* mSymbolDatabase{};
TemplateSimplifier * const mTemplateSimplifier; TemplateSimplifier * const mTemplateSimplifier;
@ -719,21 +719,21 @@ private:
std::vector<TypedefInfo> mTypedefInfo; std::vector<TypedefInfo> mTypedefInfo;
/** variable count */ /** variable count */
nonneg int mVarId; nonneg int mVarId{};
/** unnamed count "Unnamed0", "Unnamed1", "Unnamed2", ... */ /** unnamed count "Unnamed0", "Unnamed1", "Unnamed2", ... */
nonneg int mUnnamedCount; nonneg int mUnnamedCount{};
/** /**
* was there any templates? templates that are "unused" are * was there any templates? templates that are "unused" are
* removed from the token list * removed from the token list
*/ */
bool mCodeWithTemplates; bool mCodeWithTemplates{};
/** /**
* TimerResults * TimerResults
*/ */
TimerResults *mTimerResults; TimerResults* mTimerResults{};
const Preprocessor * const mPreprocessor; const Preprocessor * const mPreprocessor;
}; };

View File

@ -49,10 +49,7 @@ static const int AST_MAX_DEPTH = 150;
TokenList::TokenList(const Settings* settings) : TokenList::TokenList(const Settings* settings) :
mTokensFrontBack(), mSettings(settings)
mSettings(settings),
mIsC(false),
mIsCpp(false)
{ {
mTokensFrontBack.list = this; mTokensFrontBack.list = this;
} }
@ -396,14 +393,14 @@ std::size_t TokenList::calculateHash() const
struct AST_state { struct AST_state {
std::stack<Token*> op; std::stack<Token*> op;
int depth; int depth{};
int inArrayAssignment; int inArrayAssignment{};
bool cpp; bool cpp;
int assign; int assign{};
bool inCase; // true from case to : bool inCase{}; // true from case to :
bool stopAtColon; // help to properly parse ternary operators bool stopAtColon{}; // help to properly parse ternary operators
const Token *functionCallEndPar; const Token* functionCallEndPar{};
explicit AST_state(bool cpp) : depth(0), inArrayAssignment(0), cpp(cpp), assign(0), inCase(false),stopAtColon(false), functionCallEndPar(nullptr) {} explicit AST_state(bool cpp) : cpp(cpp) {}
}; };
static Token* skipDecl(Token* tok, std::vector<Token*>* inner = nullptr) static Token* skipDecl(Token* tok, std::vector<Token*>* inner = nullptr)

View File

@ -205,11 +205,11 @@ private:
std::vector<std::string> mOrigFiles; std::vector<std::string> mOrigFiles;
/** settings */ /** settings */
const Settings* mSettings; const Settings* mSettings{};
/** File is known to be C/C++ code */ /** File is known to be C/C++ code */
bool mIsC; bool mIsC{};
bool mIsCpp; bool mIsCpp{};
}; };
/// @} /// @}

View File

@ -3113,18 +3113,14 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
struct ExpressionAnalyzer : SingleValueFlowAnalyzer { struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
const Token* expr; const Token* expr;
bool local; bool local = true;
bool unknown; bool unknown{};
bool dependOnThis; bool dependOnThis{};
bool uniqueExprId; bool uniqueExprId{};
ExpressionAnalyzer(const Token* e, ValueFlow::Value val, const TokenList& t, const Settings* s) ExpressionAnalyzer(const Token* e, ValueFlow::Value val, const TokenList& t, const Settings* s)
: SingleValueFlowAnalyzer(std::move(val), t, s), : SingleValueFlowAnalyzer(std::move(val), t, s),
expr(e), expr(e)
local(true),
unknown(false),
dependOnThis(false),
uniqueExprId(false)
{ {
assert(e && e->exprId() != 0 && "Not a valid expression"); assert(e && e->exprId() != 0 && "Not a valid expression");
@ -3240,7 +3236,7 @@ struct SameExpressionAnalyzer : ExpressionAnalyzer {
}; };
struct OppositeExpressionAnalyzer : ExpressionAnalyzer { struct OppositeExpressionAnalyzer : ExpressionAnalyzer {
bool isNot; bool isNot{};
OppositeExpressionAnalyzer(bool pIsNot, const Token* e, ValueFlow::Value val, const TokenList& t, const Settings* s) OppositeExpressionAnalyzer(bool pIsNot, const Token* e, ValueFlow::Value val, const TokenList& t, const Settings* s)
: ExpressionAnalyzer(e, std::move(val), t, s), isNot(pIsNot) : ExpressionAnalyzer(e, std::move(val), t, s), isNot(pIsNot)
@ -3942,23 +3938,21 @@ static void valueFlowForwardLifetime(Token * tok, TokenList &tokenlist, ErrorLog
} }
struct LifetimeStore { struct LifetimeStore {
const Token *argtok; const Token* argtok{};
std::string message; std::string message;
ValueFlow::Value::LifetimeKind type; ValueFlow::Value::LifetimeKind type = ValueFlow::Value::LifetimeKind::Object;
ErrorPath errorPath; ErrorPath errorPath;
bool inconclusive; bool inconclusive{};
bool forward; bool forward = true;
struct Context { struct Context {
Token* tok; Token* tok{};
TokenList* tokenlist; TokenList* tokenlist{};
ErrorLogger* errorLogger; ErrorLogger* errorLogger{};
const Settings* settings; const Settings* settings{};
}; };
LifetimeStore() LifetimeStore() = default;
: argtok(nullptr), message(), type(), errorPath(), inconclusive(false), forward(true), mContext(nullptr)
{}
LifetimeStore(const Token* argtok, LifetimeStore(const Token* argtok,
std::string message, std::string message,
@ -3967,10 +3961,7 @@ struct LifetimeStore {
: argtok(argtok), : argtok(argtok),
message(std::move(message)), message(std::move(message)),
type(type), type(type),
errorPath(), inconclusive(inconclusive)
inconclusive(inconclusive),
forward(true),
mContext(nullptr)
{} {}
template<class F> template<class F>
@ -4055,7 +4046,7 @@ struct LifetimeStore {
update = true; update = true;
} }
if (update && forward) if (update && forward)
forwardLifetime(tok, tokenlist, errorLogger, settings); forwardLifetime(tok, &tokenlist, errorLogger, settings);
return update; return update;
} }
@ -4150,7 +4141,7 @@ struct LifetimeStore {
} }
} }
if (update && forward) if (update && forward)
forwardLifetime(tok, tokenlist, errorLogger, settings); forwardLifetime(tok, &tokenlist, errorLogger, settings);
return update; return update;
} }
@ -4226,15 +4217,15 @@ struct LifetimeStore {
} }
private: private:
Context* mContext; Context* mContext{};
void forwardLifetime(Token* tok, TokenList& tokenlist, ErrorLogger* errorLogger, const Settings* settings) const { void forwardLifetime(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
if (mContext) { if (mContext) {
mContext->tok = tok; mContext->tok = tok;
mContext->tokenlist = &tokenlist; mContext->tokenlist = tokenlist;
mContext->errorLogger = errorLogger; mContext->errorLogger = errorLogger;
mContext->settings = settings; mContext->settings = settings;
} }
valueFlowForwardLifetime(tok, tokenlist, errorLogger, settings); valueFlowForwardLifetime(tok, *tokenlist, errorLogger, settings);
} }
}; };
@ -4660,12 +4651,6 @@ static void valueFlowLifetimeConstructor(Token* tok, TokenList& tokenlist, Error
struct Lambda { struct Lambda {
explicit Lambda(const Token* tok) explicit Lambda(const Token* tok)
: capture(nullptr),
arguments(nullptr),
returnTok(nullptr),
bodyTok(nullptr),
explicitCaptures(),
implicitCapture(LifetimeCapture::Undefined)
{ {
if (!Token::simpleMatch(tok, "[") || !tok->link()) if (!Token::simpleMatch(tok, "[") || !tok->link())
return; return;
@ -4701,12 +4686,12 @@ struct Lambda {
} }
} }
const Token * capture; const Token* capture{};
const Token * arguments; const Token* arguments{};
const Token * returnTok; const Token* returnTok{};
const Token * bodyTok; const Token* bodyTok{};
std::unordered_map<const Variable*, std::pair<const Token*, LifetimeCapture>> explicitCaptures; std::unordered_map<const Variable*, std::pair<const Token*, LifetimeCapture>> explicitCaptures;
LifetimeCapture implicitCapture; LifetimeCapture implicitCapture = LifetimeCapture::Undefined;
std::vector<const Token*> getCaptures() const { std::vector<const Token*> getCaptures() const {
return getArguments(capture); return getArguments(capture);
@ -6047,7 +6032,7 @@ static void insertNegateKnown(std::list<ValueFlow::Value>& values, const std::li
struct ConditionHandler { struct ConditionHandler {
struct Condition { struct Condition {
const Token *vartok; const Token* vartok{};
std::list<ValueFlow::Value> true_values; std::list<ValueFlow::Value> true_values;
std::list<ValueFlow::Value> false_values; std::list<ValueFlow::Value> false_values;
bool inverted = false; bool inverted = false;
@ -6109,8 +6094,6 @@ struct ConditionHandler {
return ctx; return ctx;
} }
Condition() : vartok(nullptr), true_values(), false_values(), inverted(false), impossible(true) {}
}; };
virtual std::vector<Condition> parse(const Token* tok, const Settings* settings) const = 0; virtual std::vector<Condition> parse(const Token* tok, const Settings* settings) const = 0;
@ -7168,7 +7151,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
std::unordered_map<nonneg int, const Variable*> vars; std::unordered_map<nonneg int, const Variable*> vars;
MultiValueFlowAnalyzer(const std::unordered_map<const Variable*, ValueFlow::Value>& args, const TokenList& t, const Settings* set) MultiValueFlowAnalyzer(const std::unordered_map<const Variable*, ValueFlow::Value>& args, const TokenList& t, const Settings* set)
: ValueFlowAnalyzer(t, set), values(), vars() { : ValueFlowAnalyzer(t, set) {
for (const auto& p:args) { for (const auto& p:args) {
values[p.first->declarationId()] = p.second; values[p.first->declarationId()] = p.second;
vars[p.first->declarationId()] = p.first; vars[p.first->declarationId()] = p.first;

View File

@ -72,19 +72,19 @@ namespace ValueFlow {
bool isContainerSizeChanged(const Token* tok, int indirect, const Settings* settings = nullptr, int depth = 20); bool isContainerSizeChanged(const Token* tok, int indirect, const Settings* settings = nullptr, int depth = 20);
struct LifetimeToken { struct LifetimeToken {
const Token* token; const Token* token{};
Value::ErrorPath errorPath; Value::ErrorPath errorPath;
bool addressOf; bool addressOf{};
bool inconclusive; bool inconclusive{};
LifetimeToken() : token(nullptr), errorPath(), addressOf(false), inconclusive(false) {} LifetimeToken() = default;
LifetimeToken(const Token* token, Value::ErrorPath errorPath) LifetimeToken(const Token* token, Value::ErrorPath errorPath)
: token(token), errorPath(std::move(errorPath)), addressOf(false), inconclusive(false) : token(token), errorPath(std::move(errorPath))
{} {}
LifetimeToken(const Token* token, bool addressOf, Value::ErrorPath errorPath) LifetimeToken(const Token* token, bool addressOf, Value::ErrorPath errorPath)
: token(token), errorPath(std::move(errorPath)), addressOf(addressOf), inconclusive(false) : token(token), errorPath(std::move(errorPath)), addressOf(addressOf)
{} {}
static std::vector<LifetimeToken> setAddressOf(std::vector<LifetimeToken> v, bool b) { static std::vector<LifetimeToken> setAddressOf(std::vector<LifetimeToken> v, bool b) {

View File

@ -26,27 +26,10 @@
namespace ValueFlow { namespace ValueFlow {
Value::Value(const Token *c, long long val, Bound b) Value::Value(const Token *c, long long val, Bound b)
: valueType(ValueType::INT), : bound(b),
bound(b),
intvalue(val), intvalue(val),
tokvalue(nullptr),
floatValue(0.0),
varvalue(val), varvalue(val),
condition(c), condition(c) {
varId(0),
safe(false),
conditional(false),
macro(false),
defaultArg(false),
indirect(0),
moveKind(MoveKind::NonMovedVariable),
path(0),
wideintvalue(0),
subexpressions(),
capturetok(nullptr),
lifetimeKind(LifetimeKind::Object),
lifetimeScope(LifetimeScope::Local),
valueKind(ValueKind::Possible) {
errorPath.emplace_back(c, "Assuming that condition '" + c->expressionString() + "' is not redundant"); errorPath.emplace_back(c, "Assuming that condition '" + c->expressionString() + "' is not redundant");
} }

View File

@ -43,28 +43,11 @@ namespace ValueFlow
using ErrorPath = std::list<ErrorPathItem>; using ErrorPath = std::list<ErrorPathItem>;
enum class Bound { Upper, Lower, Point }; enum class Bound { Upper, Lower, Point };
explicit Value(long long val = 0, Bound b = Bound::Point) explicit Value(long long val = 0, Bound b = Bound::Point) :
: valueType(ValueType::INT),
bound(b), bound(b),
intvalue(val), intvalue(val),
tokvalue(nullptr),
floatValue(0.0),
varvalue(val), varvalue(val),
condition(nullptr), wideintvalue(val)
varId(0U),
safe(false),
conditional(false),
macro(false),
defaultArg(false),
indirect(0),
moveKind(MoveKind::NonMovedVariable),
path(0),
wideintvalue(val),
subexpressions(),
capturetok(nullptr),
lifetimeKind(LifetimeKind::Object),
lifetimeScope(LifetimeScope::Local),
valueKind(ValueKind::Possible)
{} {}
Value(const Token* c, long long val, Bound b = Bound::Point); Value(const Token* c, long long val, Bound b = Bound::Point);
@ -220,7 +203,7 @@ namespace ValueFlow
ITERATOR_START, ITERATOR_START,
ITERATOR_END, ITERATOR_END,
SYMBOLIC SYMBOLIC
} valueType; } valueType = ValueType::INT;
bool isIntValue() const { bool isIntValue() const {
return valueType == ValueType::INT; return valueType == ValueType::INT;
} }
@ -275,57 +258,57 @@ namespace ValueFlow
} }
/** The value bound */ /** The value bound */
Bound bound; Bound bound = Bound::Point;
/** int value (or sometimes bool value?) */ /** int value (or sometimes bool value?) */
long long intvalue; long long intvalue{};
/** token value - the token that has the value. this is used for pointer aliases, strings, etc. */ /** token value - the token that has the value. this is used for pointer aliases, strings, etc. */
const Token *tokvalue; const Token* tokvalue{};
/** float value */ /** float value */
double floatValue; double floatValue{};
/** 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{};
/** Condition that this value depends on */ /** Condition that this value depends on */
const Token *condition; const Token* condition{};
ErrorPath errorPath; ErrorPath errorPath;
ErrorPath debugPath; ErrorPath debugPath;
/** For calculated values - varId that calculated value depends on */ /** For calculated values - varId that calculated value depends on */
nonneg int varId; nonneg int varId{};
/** value relies on safe checking */ /** value relies on safe checking */
bool safe; bool safe{};
/** Conditional value */ /** Conditional value */
bool conditional; bool conditional{};
/** Value is is from an expanded macro */ /** Value is is from an expanded macro */
bool macro; bool macro{};
/** Is this value passed as default parameter to the function? */ /** Is this value passed as default parameter to the function? */
bool defaultArg; bool defaultArg{};
int indirect; int indirect{};
/** kind of moved */ /** kind of moved */
enum class MoveKind {NonMovedVariable, MovedVariable, ForwardedVariable} moveKind; enum class MoveKind { NonMovedVariable, MovedVariable, ForwardedVariable } moveKind = MoveKind::NonMovedVariable;
/** Path id */ /** Path id */
MathLib::bigint path; MathLib::bigint path{};
/** int value before implicit truncation */ /** int value before implicit truncation */
long long wideintvalue; long long wideintvalue{};
std::vector<std::string> subexpressions; std::vector<std::string> subexpressions;
// Set to where a lifetime is captured by value // Set to where a lifetime is captured by value
const Token* capturetok; const Token* capturetok{};
enum class LifetimeKind { enum class LifetimeKind {
// Pointer points to a member of lifetime // Pointer points to a member of lifetime
@ -338,9 +321,9 @@ namespace ValueFlow
Iterator, Iterator,
// A pointer that holds the address of the lifetime // A pointer that holds the address of the lifetime
Address Address
} lifetimeKind; } lifetimeKind = LifetimeKind::Object;
enum class LifetimeScope { Local, Argument, SubFunction, ThisPointer, ThisValue } lifetimeScope; enum class LifetimeScope { Local, Argument, SubFunction, ThisPointer, ThisValue } lifetimeScope = LifetimeScope::Local;
static const char* toString(MoveKind moveKind); static const char* toString(MoveKind moveKind);
static const char* toString(LifetimeKind lifetimeKind); static const char* toString(LifetimeKind lifetimeKind);
@ -357,7 +340,7 @@ namespace ValueFlow
Inconclusive, Inconclusive,
/** Listed values are impossible */ /** Listed values are impossible */
Impossible Impossible
} valueKind; } valueKind = ValueKind::Possible;
void setKnown() { void setKnown() {
valueKind = ValueKind::Known; valueKind = ValueKind::Known;

View File

@ -79,10 +79,7 @@ std::size_t TestFixture::todos_counter = 0;
std::size_t TestFixture::succeeded_todos_counter = 0; std::size_t TestFixture::succeeded_todos_counter = 0;
TestFixture::TestFixture(const char * const _name) TestFixture::TestFixture(const char * const _name)
: mVerbose(false), : classname(_name)
exename(),
quiet_tests(false),
classname(_name)
{ {
TestRegistry::theInstance().addTest(this); TestRegistry::theInstance().addTest(this);
} }

View File

@ -47,7 +47,7 @@ private:
static std::size_t fails_counter; static std::size_t fails_counter;
static std::size_t todos_counter; static std::size_t todos_counter;
static std::size_t succeeded_todos_counter; static std::size_t succeeded_todos_counter;
bool mVerbose; bool mVerbose{};
std::string mTemplateFormat; std::string mTemplateFormat;
std::string mTemplateLocation; std::string mTemplateLocation;
std::string mTestname; std::string mTestname;
@ -55,7 +55,7 @@ private:
protected: protected:
std::string exename; std::string exename;
std::string testToRun; std::string testToRun;
bool quiet_tests; bool quiet_tests{};
virtual void run() = 0; virtual void run() = 0;

View File

@ -481,7 +481,7 @@ private:
} }
void deleteLast() const { void deleteLast() const {
TokensFrontBack listEnds{ nullptr }; TokensFrontBack listEnds;
Token ** const tokensBack = &(listEnds.back); Token ** const tokensBack = &(listEnds.back);
Token tok(&listEnds); Token tok(&listEnds);
tok.insertToken("aba"); tok.insertToken("aba");
@ -491,7 +491,7 @@ private:
} }
void deleteFirst() const { void deleteFirst() const {
TokensFrontBack listEnds{ nullptr }; TokensFrontBack listEnds;
Token ** const tokensFront = &(listEnds.front); Token ** const tokensFront = &(listEnds.front);
Token tok(&listEnds); Token tok(&listEnds);