Skip to content

Commit 044bbb6

Browse files
committed
Address clang-tidy-21 remarks
1 parent fc572e8 commit 044bbb6

File tree

9 files changed

+34
-30
lines changed

9 files changed

+34
-30
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Checks: >
3636
-misc-non-private-member-variables-in-classes,
3737
-modernize-avoid-c-arrays,
3838
-modernize-use-trailing-return-type,
39+
-portability-avoid-pragma-once,
3940
-portability-template-virtual-member-function,
4041
-readability-magic-numbers
4142

modules/performance/include/performance.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ struct PerfAttr {
3030
struct PerfResults {
3131
/// @brief Measured execution time in seconds.
3232
double time_sec = 0.0;
33-
enum TypeOfRunning : uint8_t { kPipeline, kTaskRun, kNone } type_of_running = kNone;
33+
enum class TypeOfRunning : uint8_t { kPipeline, kTaskRun, kNone };
34+
TypeOfRunning type_of_running = TypeOfRunning::kNone;
3435
constexpr static double kMaxTime = 10.0;
3536
};
3637

@@ -116,10 +117,10 @@ class Perf {
116117
};
117118

118119
inline std::string GetStringParamName(PerfResults::TypeOfRunning type_of_running) {
119-
if (type_of_running == PerfResults::kTaskRun) {
120+
if (type_of_running == PerfResults::TypeOfRunning::kTaskRun) {
120121
return "task_run";
121122
}
122-
if (type_of_running == PerfResults::kPipeline) {
123+
if (type_of_running == PerfResults::TypeOfRunning::kPipeline) {
123124
return "pipeline";
124125
}
125126
return "none";

modules/performance/tests/perf_tests.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ TEST_P(GetStringParamNameParamTest, ReturnsExpectedString) {
175175
}
176176

177177
INSTANTIATE_TEST_SUITE_P(ParamTests, GetStringParamNameParamTest,
178-
::testing::Values(ParamTestCase{PerfResults::kTaskRun, "task_run"},
179-
ParamTestCase{PerfResults::kPipeline, "pipeline"},
178+
::testing::Values(ParamTestCase{PerfResults::TypeOfRunning::kTaskRun, "task_run"},
179+
ParamTestCase{PerfResults::TypeOfRunning::kPipeline, "pipeline"},
180180
ParamTestCase{PerfResults::TypeOfRunning::kNone, "none"}),
181181
[](const ::testing::TestParamInfo<ParamTestCase>& info) {
182182
return info.param.expected_output;
@@ -360,12 +360,12 @@ TEST(PerfTest, PipelineRunAndTaskRun) {
360360

361361
EXPECT_NO_THROW(perf.PipelineRun(attr));
362362
auto res_pipeline = perf.GetPerfResults();
363-
EXPECT_EQ(res_pipeline.type_of_running, PerfResults::kPipeline);
363+
EXPECT_EQ(res_pipeline.type_of_running, PerfResults::TypeOfRunning::kPipeline);
364364
EXPECT_GT(res_pipeline.time_sec, 0.0);
365365

366366
EXPECT_NO_THROW(perf.TaskRun(attr));
367367
auto res_taskrun = perf.GetPerfResults();
368-
EXPECT_EQ(res_taskrun.type_of_running, PerfResults::kTaskRun);
368+
EXPECT_EQ(res_taskrun.type_of_running, PerfResults::TypeOfRunning::kTaskRun);
369369
EXPECT_GT(res_taskrun.time_sec, 0.0);
370370
}
371371

@@ -380,9 +380,9 @@ TEST(PerfTest, PrintPerfStatisticThrowsOnNone) {
380380
}
381381

382382
TEST(PerfTest, GetStringParamNameTest) {
383-
EXPECT_EQ(GetStringParamName(PerfResults::kTaskRun), "task_run");
384-
EXPECT_EQ(GetStringParamName(PerfResults::kPipeline), "pipeline");
385-
EXPECT_EQ(GetStringParamName(PerfResults::kNone), "none");
383+
EXPECT_EQ(GetStringParamName(PerfResults::TypeOfRunning::kTaskRun), "task_run");
384+
EXPECT_EQ(GetStringParamName(PerfResults::TypeOfRunning::kPipeline), "pipeline");
385+
EXPECT_EQ(GetStringParamName(PerfResults::TypeOfRunning::kNone), "none");
386386
}
387387

388388
TEST(TaskTest, Destructor_InvalidPipelineOrderTerminates_PartialPipeline) {

modules/task/include/task.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace ppc::task {
2020

2121
/// @brief Represents the type of task (parallelization technology).
2222
/// @details Used to select the implementation type in tests and execution logic.
23-
enum TypeOfTask : uint8_t {
23+
enum class TypeOfTask : uint8_t {
2424
/// Use all available implementations
2525
kALL,
2626
/// MPI (Message Passing Interface)
@@ -57,7 +57,7 @@ inline std::string TypeOfTaskToString(TypeOfTask type) {
5757
}
5858

5959
/// @brief Indicates whether a task is enabled or disabled.
60-
enum StatusOfTask : uint8_t {
60+
enum class StatusOfTask : uint8_t {
6161
/// Task is enabled and should be executed
6262
kEnabled,
6363
/// Task is disabled and will be skipped
@@ -68,7 +68,7 @@ enum StatusOfTask : uint8_t {
6868
/// @param status_of_task Task status (enabled or disabled).
6969
/// @return "enabled" if the task is enabled, otherwise "disabled".
7070
inline std::string GetStringTaskStatus(StatusOfTask status_of_task) {
71-
if (status_of_task == kDisabled) {
71+
if (status_of_task == StatusOfTask::kDisabled) {
7272
return "disabled";
7373
}
7474
return "enabled";
@@ -96,7 +96,7 @@ inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string
9696
return type_str + "_" + std::string((*list_settings)["tasks"][type_str]);
9797
}
9898

99-
enum StateOfTesting : uint8_t { kFunc, kPerf };
99+
enum class StateOfTesting : uint8_t { kFunc, kPerf };
100100

101101
template <typename InType, typename OutType>
102102
/// @brief Base abstract class representing a generic task with a defined pipeline.
@@ -257,9 +257,9 @@ class Task {
257257
private:
258258
InType input_{};
259259
OutType output_{};
260-
StateOfTesting state_of_testing_ = kFunc;
261-
TypeOfTask type_of_task_ = kUnknown;
262-
StatusOfTask status_of_task_ = kEnabled;
260+
StateOfTesting state_of_testing_ = StateOfTesting::kFunc;
261+
TypeOfTask type_of_task_ = TypeOfTask::kUnknown;
262+
StatusOfTask status_of_task_ = StatusOfTask::kEnabled;
263263
std::chrono::high_resolution_clock::time_point tmp_time_point_;
264264
enum class PipelineStage : uint8_t {
265265
kNone,

modules/util/include/func_test_util.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
5050
template <typename Derived>
5151
static std::string PrintFuncTestName(const GTestFuncParam<InType, OutType, TestType>& info) {
5252
RequireStaticInterface<Derived>();
53-
TestType test_param = std::get<ppc::util::GTestParamIndex::kTestParams>(info.param);
54-
return std::get<GTestParamIndex::kNameTest>(info.param) + "_" + Derived::PrintTestParam(test_param);
53+
TestType test_param = std::get<static_cast<std::size_t>(ppc::util::GTestParamIndex::kTestParams)>(info.param);
54+
return std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(info.param) + "_" +
55+
Derived::PrintTestParam(test_param);
5556
}
5657

5758
protected:
5859
void ExecuteTest(FuncTestParam<InType, OutType, TestType> test_param) {
59-
const std::string& test_name = std::get<GTestParamIndex::kNameTest>(test_param);
60+
const std::string& test_name = std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(test_param);
6061

6162
ValidateTestName(test_name);
6263

@@ -90,7 +91,7 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
9091

9192
/// @brief Initializes task instance and runs it through the full pipeline.
9293
void InitializeAndRunTask(const FuncTestParam<InType, OutType, TestType>& test_param) {
93-
task_ = std::get<GTestParamIndex::kTaskGetter>(test_param)(GetTestInputData());
94+
task_ = std::get<static_cast<std::size_t>(GTestParamIndex::kTaskGetter)>(test_param)(GetTestInputData());
9495
ExecuteTaskPipeline();
9596
}
9697

modules/util/include/perf_test_util.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
3535
public:
3636
/// @brief Generates a readable name for the performance test case.
3737
static std::string CustomPerfTestName(const ::testing::TestParamInfo<PerfTestParam<InType, OutType>>& info) {
38-
return ppc::performance::GetStringParamName(std::get<GTestParamIndex::kTestParams>(info.param)) + "_" +
39-
std::get<GTestParamIndex::kNameTest>(info.param);
38+
return ppc::performance::GetStringParamName(
39+
std::get<static_cast<std::size_t>(GTestParamIndex::kTestParams)>(info.param)) +
40+
"_" + std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(info.param);
4041
}
4142

4243
protected:
@@ -67,9 +68,9 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
6768
}
6869

6970
void ExecuteTest(const PerfTestParam<InType, OutType>& perf_test_param) {
70-
auto task_getter = std::get<GTestParamIndex::kTaskGetter>(perf_test_param);
71-
auto test_name = std::get<GTestParamIndex::kNameTest>(perf_test_param);
72-
auto mode = std::get<GTestParamIndex::kTestParams>(perf_test_param);
71+
auto task_getter = std::get<static_cast<std::size_t>(GTestParamIndex::kTaskGetter)>(perf_test_param);
72+
auto test_name = std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(perf_test_param);
73+
auto mode = std::get<static_cast<std::size_t>(GTestParamIndex::kTestParams)>(perf_test_param);
7374

7475
ASSERT_FALSE(test_name.find("unknown") != std::string::npos);
7576
if (test_name.find("disabled") != std::string::npos) {

modules/util/include/util.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class DestructorFailureFlag {
5353
inline static std::atomic<bool> failure_flag{false};
5454
};
5555

56-
enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };
56+
enum class GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };
5757

5858
std::string GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path);
5959
int GetNumThreads();
@@ -70,7 +70,7 @@ std::string GetNamespace() {
7070
std::free};
7171
name = (status == 0) ? demangled.get() : name;
7272
#endif
73-
#if defined(_MSC_VER)
73+
#ifdef _MSC_VER
7474
const std::string prefixes[] = {"class ", "struct ", "enum ", "union "};
7575
for (const auto& prefix : prefixes) {
7676
if (name.starts_with(prefix)) {

tasks/example_processes/tests/functional/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class NesterovARunFuncTestsProcesses : public ppc::util::BaseRunFuncTests<InType
4646
}
4747
}
4848

49-
TestType params = std::get<ppc::util::GTestParamIndex::kTestParams>(GetParam());
49+
TestType params = std::get<static_cast<std::size_t>(ppc::util::GTestParamIndex::kTestParams)>(GetParam());
5050
input_data_ = width - height + std::min(std::accumulate(img.begin(), img.end(), 0), channels);
5151
}
5252

tasks/example_threads/tests/functional/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class NesterovARunFuncTestsThreads : public ppc::util::BaseRunFuncTests<InType,
4949
}
5050
}
5151

52-
TestType params = std::get<ppc::util::GTestParamIndex::kTestParams>(GetParam());
52+
TestType params = std::get<static_cast<std::size_t>(ppc::util::GTestParamIndex::kTestParams)>(GetParam());
5353
input_data_ = width - height + std::min(std::accumulate(img.begin(), img.end(), 0), channels);
5454
}
5555

0 commit comments

Comments
 (0)