Skip to content

Commit 1be5af7

Browse files
authored
enabled and fixed performance-enum-size clang-tidy warnings (cppcheck-opensource#6221)
1 parent 83f890a commit 1be5af7

60 files changed

Lines changed: 162 additions & 121 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Checks: >
5151
-modernize-use-nodiscard,
5252
-modernize-use-trailing-return-type,
5353
-performance-avoid-endl,
54-
-performance-enum-size,
5554
-performance-inefficient-string-concatenation,
5655
-performance-no-automatic-move,
5756
-performance-noexcept-swap,

clang-tidy.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as
125125
`performance-noexcept-swap`<br/>
126126
`bugprone-switch-missing-default-case`<br/>
127127
`bugprone-empty-catch`<br/>
128-
`performance-enum-size`<br/>
129128
`readability-avoid-nested-conditional-operator`</br>
130129

131130
To be evaluated (need to remove exclusion).

cli/cmdlineparser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define CMDLINE_PARSER_H
2121

2222
#include <cstddef>
23+
#include <cstdint>
2324
#include <list>
2425
#include <string>
2526
#include <vector>
@@ -55,7 +56,7 @@ class CmdLineParser {
5556
*/
5657
CmdLineParser(CmdLineLogger &logger, Settings &settings, Suppressions &suppressions);
5758

58-
enum class Result { Success, Exit, Fail };
59+
enum class Result : std::uint8_t { Success, Exit, Fail };
5960

6061
/**
6162
* @brief Parse command line args and fill settings and file lists

cli/processexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#include <sys/prctl.h>
5858
#endif
5959

60-
enum class Color;
60+
enum class Color : std::uint8_t;
6161

6262
// NOLINTNEXTLINE(misc-unused-using-decls) - required for FD_ZERO
6363
using std::memset;
@@ -73,7 +73,7 @@ ProcessExecutor::ProcessExecutor(const std::list<FileWithDetails> &files, const
7373
namespace {
7474
class PipeWriter : public ErrorLogger {
7575
public:
76-
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', CHILD_END='5'};
76+
enum PipeSignal : std::uint8_t {REPORT_OUT='1',REPORT_ERROR='2', CHILD_END='5'};
7777

7878
explicit PipeWriter(int pipe) : mWpipe(pipe) {}
7979

cli/threadexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <utility>
3939
#include <vector>
4040

41-
enum class Color;
41+
enum class Color : std::uint8_t;
4242

4343
ThreadExecutor::ThreadExecutor(const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand)
4444
: Executor(files, fileSettings, settings, suppressions, errorLogger)

gui/checkthread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "suppressions.h"
2525

2626
#include <atomic>
27+
#include <cstdint>
2728
#include <string>
2829
#include <vector>
2930

@@ -115,7 +116,7 @@ class CheckThread : public QThread {
115116
* has been completed. Thread must be stopped cleanly, just terminating thread
116117
* likely causes unpredictable side-effects.
117118
*/
118-
enum State {
119+
enum State : std::uint8_t {
119120
Running, /**< The thread is checking. */
120121
Stopping, /**< The thread will stop after current work. */
121122
Stopped, /**< The thread has been stopped. */

gui/codeeditor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef CODEEDITOR_H
2020
#define CODEEDITOR_H
2121

22+
#include <cstdint>
23+
2224
#include <QObject>
2325
#include <QPlainTextEdit>
2426
#include <QRegularExpression>
@@ -51,7 +53,7 @@ class Highlighter : public QSyntaxHighlighter {
5153
void highlightBlock(const QString &text) override;
5254

5355
private:
54-
enum RuleRole {
56+
enum RuleRole : std::uint8_t {
5557
Keyword = 1,
5658
Class = 2,
5759
Comment = 3,

gui/cppchecklibrarydata.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef CPPCHECKLIBRARYDATA_H
2020
#define CPPCHECKLIBRARYDATA_H
2121

22+
#include <cstdint>
23+
2224
#include <QList>
2325
#include <QMap>
2426
#include <QPair>
@@ -72,7 +74,7 @@ class CppcheckLibraryData {
7274
struct Function {
7375
QString comments;
7476
QString name;
75-
enum TrueFalseUnknown { False, True, Unknown } noreturn = Unknown;
77+
enum TrueFalseUnknown : std::uint8_t { False, True, Unknown } noreturn = Unknown;
7678
bool gccPure{};
7779
bool gccConst{};
7880
bool leakignore{};

gui/mainwindow.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "library.h"
2323
#include "platforms.h"
2424

25+
#include <cstdint>
26+
2527
#include <QFileDialog>
2628
#include <QMainWindow>
2729
#include <QObject>
@@ -62,7 +64,7 @@ class MainWindow : public QMainWindow {
6264
/**
6365
* @brief Maximum number of MRU project items in File-menu.
6466
*/
65-
enum { MaxRecentProjects = 5 };
67+
enum : std::uint8_t { MaxRecentProjects = 5 };
6668

6769
MainWindow(TranslationHandler* th, QSettings* settings);
6870
MainWindow(const MainWindow &) = delete;

gui/newsuppressiondialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <QStringList>
3232

3333
class QWidget;
34-
enum class Color;
34+
enum class Color : std::uint8_t;
3535

3636
NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
3737
QDialog(parent),

0 commit comments

Comments
 (0)