Skip to content

Commit

Permalink
Apply more clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
davschneller committed Nov 13, 2024
1 parent 20d2eac commit b1c4ee4
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 15 deletions.
26 changes: 26 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@
#
# SPDX-License-Identifier: BSD-3-Clause

# TODO: apply
# * modernize-use-trailing-return-type
# * readability-function-size
# * cppcoreguidelines-pro-type-const-cast
# * readability-convert-member-functions-to-static

Checks: |
-*,
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-pro-type-member-init,
-cppcoreguidelines-pro-type-const-cast
llvm-*,
-llvm-else-after-return,
-llvm-header-guard,
Expand All @@ -23,12 +36,25 @@ Checks: |
-misc-unused-parameters,
-misc-no-recursion,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-loop-convert,
-modernize-pass-by-value,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
mpi-*,
performance-*,
-performance-enum-size,
-performance-avoid-endl,
readability-*,
-readability-else-after-return,
-readability-identifier-length,
-readability-magic-numbers,
-readability-math-missing-parentheses,
-readability-function-cognitive-complexity,
-readability-function-size
-readability-suspicious-call-argument,
-readability-convert-member-functions-to-static,
WarningsAsErrors: '*'
CheckOptions:
# - key: readability-identifier-naming.AbstractClassCase
Expand Down
1 change: 1 addition & 0 deletions async/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef ASYNC_CONFIG_H
#define ASYNC_CONFIG_H

#include <cstddef>
#include <string>

#include "utils/env.h"
Expand Down
6 changes: 3 additions & 3 deletions async/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#define ASYNC_MODULE_H

#include "async/BufferOrigin.h"
#include "async/as/Base.h"
#include "async/as/MPIScheduler.h"
#include <cstddef>
#include <memory>
#ifdef USE_MPI
#include <mpi.h>
#endif // USE_MPI

#ifdef USE_MPI
#include "async/as/MPI.h"
Expand Down
21 changes: 11 additions & 10 deletions async/as/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <type_traits>
#include <vector>

#include "Pin.h"
Expand All @@ -36,10 +37,10 @@ class MPIScheduler;
template <class Executor, typename InitParameter = NoParam, typename Parameter = NoParam>
class Base : public async::ExecInfo {
private:
ASYNC_HAS_MEM_FUNC_T1(execInit, execInitHasExec, P, void, const ExecInfo&, const P&);
ASYNC_HAS_MEM_FUNC_T1(exec, execHasExec, P, void, const ExecInfo&, const P&);
ASYNC_HAS_MEM_FUNC_T1(execWait, execWaitHasExec, P, void, const ExecInfo&);
ASYNC_HAS_MEM_FUNC_T1(execWait, execWaitHasNoExec, P, void);
ASYNC_HAS_MEM_FUNC_T1(execInit, ExecInitHasExec, P, void, const ExecInfo&, const P&);
ASYNC_HAS_MEM_FUNC_T1(exec, ExecHasExec, P, void, const ExecInfo&, const P&);
ASYNC_HAS_MEM_FUNC_T1(execWait, ExecWaitHasExec, P, void, const ExecInfo&);
ASYNC_HAS_MEM_FUNC_T1(execWait, ExecWaitHasNoExec, P, void);

/**
* Description of a buffer
Expand Down Expand Up @@ -276,37 +277,37 @@ class Base : public async::ExecInfo {

template <typename E, typename P>
auto callInitInternal(const P& parameters) ->
typename std::enable_if_t<execInitHasExec<E, P>::Value> {
typename std::enable_if_t<ExecInitHasExec<E, P>::Value> {
const ExecInfo& info = *this;
m_executor->execInit(info, parameters);
}

template <typename E, typename P>
auto callInitInternal(const P& parameters) ->
typename std::enable_if_t<!execInitHasExec<E, P>::Value> {
typename std::enable_if_t<!ExecInitHasExec<E, P>::Value> {
m_executor->execInit(parameters);
}

template <typename E, typename P>
auto callInternal(const P& parameters) -> typename std::enable_if_t<execHasExec<E, P>::Value> {
auto callInternal(const P& parameters) -> typename std::enable_if_t<ExecHasExec<E, P>::Value> {
const ExecInfo& info = *this;
m_executor->exec(info, parameters);
}

template <typename E, typename P>
auto callInternal(const P& parameters) -> typename std::enable_if_t<!execHasExec<E, P>::Value> {
auto callInternal(const P& parameters) -> typename std::enable_if_t<!ExecHasExec<E, P>::Value> {
m_executor->exec(parameters);
}

template <typename E, typename P>
auto callWaitInternal() -> typename std::enable_if_t<execWaitHasExec<E, P>::Value> {
auto callWaitInternal() -> typename std::enable_if_t<ExecWaitHasExec<E, P>::Value> {
const ExecInfo& info = *this;
m_executor->execWait(info);
}

template <typename E, typename P>
auto callWaitInternal() ->
typename std::enable_if_t<!execWaitHasNoExec<E, P>::Value && !execWaitHasExec<E, P>::Value> {}
typename std::enable_if_t<!ExecWaitHasNoExec<E, P>::Value && !ExecWaitHasExec<E, P>::Value> {}
};

} // namespace async::as
Expand Down
3 changes: 2 additions & 1 deletion async/as/MPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
#ifndef ASYNC_AS_MPI_H
#define ASYNC_AS_MPI_H

#include <mpi.h>
#include <cstddef>

#include <cassert>

#include "MPIBase.h"
#include "async/as/Base.h"

namespace async::as {

Expand Down
4 changes: 4 additions & 0 deletions async/as/MPIAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
#ifndef ASYNC_AS_MPIASYNC_H
#define ASYNC_AS_MPIASYNC_H

#include <cstddef>
#include <mpi.h>

#include <cassert>
#include <vector>

#include "MPIBase.h"
#include "async/ExecInfo.h"
#include "async/as/Base.h"
#include "async/as/MPIScheduler.h"

namespace async::as {

Expand Down
3 changes: 3 additions & 0 deletions async/as/MPIBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef ASYNC_AS_MPIBASE_H
#define ASYNC_AS_MPIBASE_H

#include <cstdint>
#include <algorithm>
#include <mpi.h>

#include <cassert>
Expand All @@ -21,6 +23,7 @@
#include "MPIScheduler.h"
#include "ThreadBase.h"
#include "async/Config.h"
#include "async/as/Base.h"

namespace async::as {

Expand Down
4 changes: 4 additions & 0 deletions async/as/Pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

#include <pthread.h>

#ifndef __APPLE__
#include <sched.h>
#endif

namespace async::as {
struct CpuMask {
#ifndef __APPLE__
Expand Down
1 change: 1 addition & 0 deletions async/as/Sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "Base.h"
#include "async/ExecInfo.h"
#include <cstddef>

namespace async::as {

Expand Down
5 changes: 5 additions & 0 deletions async/as/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
#ifndef ASYNC_AS_THREAD_H
#define ASYNC_AS_THREAD_H

#include "async/as/Pin.h"
#include "utils/logger.h"
#include "async/as/Base.h"
#include "async/ExecInfo.h"
#include <cassert>
#include <cstring>
#include <sched.h>
#include <vector>
#ifndef __APPLE__
#include <sys/sysinfo.h>
#endif // __APPLE__
Expand Down
2 changes: 1 addition & 1 deletion async/as/ThreadBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#ifndef ASYNC_AS_THREADBASE_H
#define ASYNC_AS_THREADBASE_H

#include <cassert>
#include <cstring>
#include <optional>
#include <pthread.h>
#include <sched.h>

#include "utils/logger.h"

Expand Down
3 changes: 3 additions & 0 deletions tests/Module.t.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* @author Sebastian Rettenberger <[email protected]>
*/

#include "async/ExecInfo.h"
#include <array>
#include <sys/sysinfo.h>
#ifdef USE_MPI
#include <mpi.h>
#endif // USE_MPI
Expand Down
5 changes: 5 additions & 0 deletions tests/as/MPI.t.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
* @author Sebastian Rettenberger <[email protected]>
*/

#include <cstddef>
#include "async/Config.h"
#include "async/as/MPIScheduler.h"
#include <array>
#include <mpi.h>

#include <pthread.h>
#include <vector>

#include <cxxtest/GlobalFixture.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/as/Thread.t.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
#include <cstdlib>
#include <ctime>
#include <pthread.h>
#include <sched.h>
#include <sys/sysinfo.h>

#include "Executor.h"
#include "async/as/Pin.h"
#include "async/as/Thread.h"

class TestThread : public CxxTest::TestSuite {
Expand Down
1 change: 1 addition & 0 deletions tests/as/Thread_buffer.t.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @author Sebastian Rettenberger <[email protected]>
*/

#include <cstdint>
#include <cxxtest/TestSuite.h>

#include <cmath>
Expand Down

0 comments on commit b1c4ee4

Please sign in to comment.