Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
dacd2fa
Use in-class initializers, default constructors, class -> struct
chrchr-github Mar 1, 2023
8be07e0
Format
chrchr-github Mar 1, 2023
cd89650
Missing init, more constructors
chrchr-github Mar 1, 2023
cdb56ba
Fix compiler error
chrchr-github Mar 1, 2023
85f2632
Missing init
chrchr-github Mar 1, 2023
f3d693e
Missing init
chrchr-github Mar 1, 2023
8a9424b
Restore init
chrchr-github Mar 1, 2023
18b2ff5
Duplicate
chrchr-github Mar 1, 2023
245889a
More constructors, rule of zero
chrchr-github Mar 1, 2023
d506867
More constructors
chrchr-github Mar 1, 2023
206de7d
Fix init
chrchr-github Mar 2, 2023
b5278c9
Undo
chrchr-github Mar 2, 2023
500ca9a
More constructors
chrchr-github Mar 2, 2023
1784841
Format
chrchr-github Mar 2, 2023
549a016
Workaround for internalAstError
chrchr-github Mar 2, 2023
d6e38fe
Fix compiler error
chrchr-github Mar 2, 2023
b5ed91e
clang-tidy
chrchr-github Mar 2, 2023
081402e
More workarounds
chrchr-github Mar 2, 2023
f0a292b
Another enum fix
chrchr-github Mar 2, 2023
b8f2095
Amend
chrchr-github Mar 2, 2023
06704f2
Amend again
chrchr-github Mar 2, 2023
8895983
Enum fix
chrchr-github Mar 2, 2023
22a6bf6
Enum fix
chrchr-github Mar 2, 2023
b735c8f
Enable clang-tidy checks
chrchr-github Mar 2, 2023
32c637c
Fix warnings
chrchr-github Mar 18, 2023
1126001
Merge
chrchr-github Mar 18, 2023
dd8aa5a
Amend
chrchr-github Mar 18, 2023
4a0090c
Fix warnings
chrchr-github Mar 18, 2023
6e6e803
Fix GUI warnings
chrchr-github Mar 18, 2023
5ec31f0
Typo, redundant initializer
chrchr-github Mar 18, 2023
95f171c
Redundant definition
chrchr-github Mar 19, 2023
c75f4d2
Init fixes
chrchr-github Apr 4, 2023
c34a40f
Merge
chrchr-github Apr 10, 2023
1fdcf34
Amend
chrchr-github Apr 10, 2023
b69be93
Fix merge
chrchr-github Apr 10, 2023
08482af
Undo
chrchr-github Apr 10, 2023
ca414cd
Merge branch 'main' into chr_constructors
chrchr-github Apr 10, 2023
41f5085
Fix merge
chrchr-github Apr 10, 2023
ce5aedc
Merge branch 'chr_constructors' of https://github.com/chrchr-github/c…
chrchr-github Apr 10, 2023
8890000
Merge, format .clang.tidy
chrchr-github May 3, 2023
b66c9a1
Merge
chrchr-github May 3, 2023
59fec1f
Use = 0
chrchr-github May 3, 2023
6e8e0ee
Format
chrchr-github May 3, 2023
fea2f46
Fix .clang-tidy
chrchr-github May 3, 2023
d0d1be4
Merge
chrchr-github May 4, 2023
043226b
Merge
chrchr-github May 12, 2023
4fc5cba
Merge branch 'danmar:main' into chr_constructors
chrchr-github May 29, 2023
48bba24
Merge
chrchr-github Jun 16, 2023
5d913dd
Merge
chrchr-github Jun 16, 2023
97193c4
Fix merge
chrchr-github Jun 16, 2023
1993756
Fix merge
chrchr-github Jun 17, 2023
45e1d15
Merge
chrchr-github Jun 23, 2023
60666f1
Merge
chrchr-github Jun 26, 2023
3f73305
Merge
chrchr-github Aug 3, 2023
44fe7f2
Merge
chrchr-github Aug 7, 2023
a6f613d
Merge
chrchr-github Aug 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -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: >
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format is not supported in older clang-tidy versions which we implicitly still support as we also support older Clang versions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who uses our .clang-tidy except us? There is a way to get line-wise formatting in older versions as well, but it's ugly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who uses our .clang-tidy except us?

Every user who has an editor which support clang-tidy.

There is a way to get line-wise formatting in older versions as well, but it's ugly.

I know. If possible I would have used that already. The problem is that YAML parser in LLVM is not complete and only supports the bare minimum of features required. So, no.

The multi-line format was not added until about 3 years ago IIRC. We need to do some tests to figure out which version that was. As ubuntu 20.04 is definitely one of the operating systems we should properly support as a dev system it is quite possible we slightly missed that.

Another problem is, that it fails silently. So it will just ignore the option and will use the default checks.

They also just recently changed the default format to more modern YAML which is also not backwards compatible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	Checks: '
		,*,
		,-bugprone-assignment-in-if-condition,
		,-bugprone-easily-swappable-parameters,
	'

This is what I meant above, it should work with older clangs.
But even if there were developers (not users) on older systems, using an old clang makes little sense, since we have the current version in our CI, which needs to pass eventually.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I meant above, it should work with older clangs.

I will give it a spin later today. I have several older versions installed.

But even if there were developers (not users) on older systems, using an old clang makes little sense, since we have the current version in our CI, which needs to pass eventually.

I think using any LTS version is justified. ubuntu 20.04 (still supported until at least 2025) comes with Clang 10 out of the box and it seems there's also an official repo with Clang 13. But distros rarely update such major packages after release. There's also the possibility to install the latest via the LLVM repo. But it also depends on your IDE integration. But the length of the LTS support windows have been getting quite ridiculous. I happy that non-LTS versions usually get discarded as soon as the next non-LTS ones are out. But unfortunately that solidifies the usage of older LTS versions.

Just take a look at the LLVM bug tracker. They frequently get reports for older versions.

Or ubuntu Touch - they have been working for years now to move off ubuntu 16.04 and just recently achieved their move to ubuntu 20.04. It is unlikely that their CI is using the latest compilers.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to open up the discussions here so we don't go off-topic so often.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to open up the discussions here so we don't go off-topic so often.

any reason to not use the forum on sourceforge? We don't need several forums.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all development happens on Github, we might also close Sourceforge and focus on a single site. Probably more people are already on Github than on Sourceforge.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every user who has an editor which support clang-tidy.

That sounds a lot. But cppcheck users will not see this file. This is not installed.

I would say it's only cppcheck developers that might use this. And well most developers will likely not use this file neither locally. I assume it makes sense to use it locally only if you have the same clang-tidy version as CI because there are different checkers in different versions.

*,
-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: '*'
HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h'
CheckOptions:
Expand Down
8 changes: 3 additions & 5 deletions clang-tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@ These are coding guidelines we do not follow. Some of the checks might be explic
`modernize-use-auto`<br>
`readability-uppercase-literal-suffix`<br>
`readability-else-after-return`<br>
`modernize-use-default-member-init`<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-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-redundant-member-init`<br>

These do not (always) increase readability.

Expand All @@ -58,7 +56,7 @@ To be documented.

`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>
`performance-no-automatic-move`<br>
Expand Down
4 changes: 0 additions & 4 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ CmdLineParser::CmdLineParser(Settings &settings, Suppressions &suppressions, Sup
: mSettings(settings)
, mSuppressions(suppressions)
, mSuppressionsNoFail(suppressionsNoFail)
, mShowHelp(false)
, mShowVersion(false)
, mShowErrorMessages(false)
, mExitAfterPrint(false)
{}

void CmdLineParser::printMessage(const std::string &message)
Expand Down
8 changes: 4 additions & 4 deletions cli/cmdlineparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ class CmdLineParser {
Settings &mSettings;
Suppressions &mSuppressions;
Suppressions &mSuppressionsNoFail;
bool mShowHelp;
bool mShowVersion;
bool mShowErrorMessages;
bool mExitAfterPrint;
bool mShowHelp{};
bool mShowVersion{};
bool mShowErrorMessages{};
bool mExitAfterPrint{};
std::string mVSConfig;
};

Expand Down
4 changes: 0 additions & 4 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@

/*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout;

CppCheckExecutor::CppCheckExecutor()
: mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mShowAllErrors(false)
{}

CppCheckExecutor::~CppCheckExecutor()
{
delete mErrorOutput;
Expand Down
10 changes: 5 additions & 5 deletions cli/cppcheckexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Constructor
*/
CppCheckExecutor();
CppCheckExecutor() = default;
CppCheckExecutor(const CppCheckExecutor &) = delete;
void operator=(const CppCheckExecutor&) = delete;

Expand Down Expand Up @@ -154,7 +154,7 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Pointer to current settings; set while check() is running for reportError().
*/
const Settings* mSettings;
const Settings* mSettings{};

/**
* Used to filter out duplicate error messages.
Expand All @@ -169,7 +169,7 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Report progress time
*/
std::time_t mLatestProgressOutputTime;
std::time_t mLatestProgressOutputTime{};

/**
* Output file name for exception handler
Expand All @@ -179,12 +179,12 @@ class CppCheckExecutor : public ErrorLogger {
/**
* Error output
*/
std::ofstream *mErrorOutput;
std::ofstream* mErrorOutput{};

/**
* Has --errorlist been given?
*/
bool mShowAllErrors;
bool mShowAllErrors{};
};

#endif // CPPCHECKEXECUTOR_H
10 changes: 5 additions & 5 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ThreadData
{
public:
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();
mItNextFileSettings = mFileSettings.begin();
Expand Down Expand Up @@ -148,10 +148,10 @@ class ThreadData
const std::list<ImportProject::FileSettings> &mFileSettings;
std::list<ImportProject::FileSettings>::const_iterator mItNextFileSettings;

std::size_t mProcessedFiles;
std::size_t mTotalFiles;
std::size_t mProcessedSize;
std::size_t mTotalFileSize;
std::size_t mProcessedFiles{};
std::size_t mTotalFiles{};
std::size_t mProcessedSize{};
std::size_t mTotalFileSize{};

std::mutex mFileSync;
const Settings &mSettings;
Expand Down
3 changes: 1 addition & 2 deletions gui/applicationlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
#include <QVariant>

ApplicationList::ApplicationList(QObject *parent) :
QObject(parent),
mDefaultApplicationIndex(-1)
QObject(parent)
{
//ctor
}
Expand Down
2 changes: 1 addition & 1 deletion gui/applicationlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ApplicationList : public QObject {
* @brief Index of the default application.
*
*/
int mDefaultApplicationIndex;
int mDefaultApplicationIndex = -1;
};
/// @}
#endif // APPLICATIONLIST_H
4 changes: 1 addition & 3 deletions gui/checkthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ static bool executeCommand(std::string exe, std::vector<std::string> args, std::


CheckThread::CheckThread(ThreadResult &result) :
mState(Ready),
mResult(result),
mCppcheck(result, true, executeCommand),
mAnalyseWholeProgram(false)
mCppcheck(result, true, executeCommand)
{
//ctor
}
Expand Down
4 changes: 2 additions & 2 deletions gui/checkthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CheckThread : public QThread {
/**
* @brief Thread's current execution state.
*/
State mState;
State mState = Ready;

ThreadResult &mResult;
/**
Expand All @@ -136,7 +136,7 @@ class CheckThread : public QThread {
bool isSuppressed(const Suppressions::ErrorMessage &errorMessage) const;

QStringList mFiles;
bool mAnalyseWholeProgram;
bool mAnalyseWholeProgram{};
QStringList mAddonsAndTools;
QStringList mClangIncludePaths;
QList<Suppressions::Suppression> mSuppressions;
Expand Down
1 change: 0 additions & 1 deletion gui/codeeditorstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ CodeEditorStyle::CodeEditorStyle(
// cppcheck-suppress naming-varname - TODO: fix this
QColor SymbFGColor, QColor SymbBGColor,
const QFont::Weight& SymbWeight) :
mSystemTheme(false),
widgetFGColor(std::move(CtrlFGColor)),
widgetBGColor(std::move(CtrlBGColor)),
highlightBGColor(std::move(HiLiBGColor)),
Expand Down
2 changes: 1 addition & 1 deletion gui/codeeditorstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CodeEditorStyle {
static void saveSettings(QSettings *settings, const CodeEditorStyle& theStyle);

public:
bool mSystemTheme;
bool mSystemTheme{};
QColor widgetFGColor;
QColor widgetBGColor;
QColor highlightBGColor;
Expand Down
3 changes: 1 addition & 2 deletions gui/codeeditstylecontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ const QColor& SelectColorButton::getColor()
}

SelectFontWeightCombo::SelectFontWeightCombo(QWidget* parent) :
QComboBox(parent),
mWeight(QFont::Normal)
QComboBox(parent)
{
addItem(QObject::tr("Thin"),
QVariant(static_cast<int>(QFont::Thin)));
Expand Down
2 changes: 1 addition & 1 deletion gui/codeeditstylecontrols.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public slots:
void changeWeight(int index);

private:
QFont::Weight mWeight;
QFont::Weight mWeight = QFont::Normal;
};

#endif //CODEEDITORSTYLECONTROLS_H
Expand Down
Loading