Skip to content

Commit d1c32a8

Browse files
authored
Enable 'concurrency-*' checks in clang-tidy (#406)
1 parent fd8a908 commit d1c32a8

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Checks: >
22
bugprone-*,
33
clang-diagnostic-*,
4+
concurrency-*,
45
cppcoreguidelines-*,
56
llvm-include-order,
67
llvm-namespace-comment,

modules/core/task/src/task.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ppc::core::Task::Task(StateOfTesting state_of_testing) : state_of_testing_(state
1919
auto custom_terminate = []() {
2020
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT! \n"
2121
"Expected - \"Validation\", \"PreProcessing\", \"Run\", \"PostProcessing\" \n";
22-
std::exit(404);
2322
};
2423
std::set_terminate(custom_terminate);
2524
functions_order_.clear();

modules/core/util/func_tests/util_tests.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ TEST(util_tests, check_unset_env) {
1010
#ifndef _WIN32
1111
int save_var = ppc::util::GetPPCNumThreads();
1212

13-
unsetenv("OMP_NUM_THREADS"); // NOLINT(misc-include-cleaner)
13+
unsetenv("OMP_NUM_THREADS"); // NOLINT(concurrency-mt-unsafe,misc-include-cleaner)
1414

1515
EXPECT_EQ(ppc::util::GetPPCNumThreads(), 1);
1616

17-
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(misc-include-cleaner)
17+
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(concurrency-mt-unsafe,misc-include-cleaner)
1818
#else
1919
GTEST_SKIP();
2020
#endif
@@ -25,11 +25,12 @@ TEST(util_tests, check_set_env) {
2525
int save_var = ppc::util::GetPPCNumThreads();
2626

2727
const int num_threads = static_cast<int>(std::thread::hardware_concurrency());
28-
setenv("OMP_NUM_THREADS", std::to_string(num_threads).c_str(), 1); // NOLINT(misc-include-cleaner)
28+
// NOLINTNEXTLINE(concurrency-mt-unsafe,misc-include-cleaner)
29+
setenv("OMP_NUM_THREADS", std::to_string(num_threads).c_str(), 1);
2930

3031
EXPECT_EQ(ppc::util::GetPPCNumThreads(), num_threads);
3132

32-
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(misc-include-cleaner)
33+
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(concurrency-mt-unsafe,misc-include-cleaner)
3334
#else
3435
GTEST_SKIP();
3536
#endif

modules/core/util/src/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int ppc::util::GetPPCNumThreads() {
2626
}
2727
int num_threads = std::atoi(omp_env);
2828
#else
29-
const char *omp_env = std::getenv("OMP_NUM_THREADS");
29+
const char *omp_env = std::getenv("OMP_NUM_THREADS"); // NOLINT(concurrency-mt-unsafe)
3030
int num_threads = (omp_env != nullptr) ? std::atoi(omp_env) : 1;
3131
#endif
3232
return num_threads;

tasks/all/runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
3131
"[ PROCESS %d ] [ FAILED ] %s.%s: MPI message queue has an unread message from process %d with tag %d\n",
3232
rank, "test_suite_name", "test_name", status.MPI_SOURCE, status.MPI_TAG);
3333
MPI_Finalize();
34-
exit(2);
34+
std::abort();
3535
}
3636

3737
MPI_Barrier(MPI_COMM_WORLD);

tasks/mpi/runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
2828
"[ PROCESS %d ] [ FAILED ] %s.%s: MPI message queue has an unread message from process %d with tag %d\n",
2929
rank, "test_suite_name", "test_name", status.MPI_SOURCE, status.MPI_TAG);
3030
MPI_Finalize();
31-
exit(2);
31+
std::abort();
3232
}
3333

3434
MPI_Barrier(MPI_COMM_WORLD);

0 commit comments

Comments
 (0)