Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 39 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Checks: '
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-move-forwarding-reference,
-bugprone-narrowing-conversions,
-bugprone-reserved-identifier,
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
-misc-unconventional-assign-operator,
-misc-unused-parameters,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-concat-nested-namespaces,
-modernize-deprecated-headers,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-modernize-use-using,
performance-*,
-performance-noexcept-move-constructor,
readability-*,
-readability-braces-around-statements,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-inconsistent-declaration-parameter-name,
-readability-magic-numbers,
-readability-named-parameter,
-readability-uppercase-literal-suffix,
-readability-use-anyofallof,
'
CheckOptions:
- key: modernize-use-override.IgnoreDestructors
value: true
HeaderFilterRegex: 'example/calculator.h|example/init.h|example/printer.h|include/mp/proxy-io.h|include/mp/proxy-types.h|include/mp/proxy.h|include/mp/util.h|test/mp/test/foo-types.h|test/mp/test/foo.h'
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ project("Libmultiprocess" CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

option(Libmultiprocess_ENABLE_CLANG_TIDY "Run clang-tidy with the compiler." OFF)
if(Libmultiprocess_ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXECUTABLE NAMES clang-tidy)
if(NOT CLANG_TIDY_EXECUTABLE)
message(FATAL_ERROR "Libmultiprocess_ENABLE_CLANG_TIDY is ON but clang-tidy is not found.")
endif()
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
endif()

include(CMakePushCheckState)
include(CheckCXXSourceCompiles)
include(GNUInstallDirs)
Expand Down
6 changes: 3 additions & 3 deletions include/mp/proxy-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class EventLoop
logger << "{" << LongThreadName(m_exe_name) << "} ";
return logger;
}
Logger logPlain() { return Logger(false, m_log_fn); }
Logger raise() { return Logger(true, m_log_fn); }
Logger logPlain() { return {false, m_log_fn}; }
Logger raise() { return {true, m_log_fn}; }

//! Process name included in thread names so combined debug output from
//! multiple processes is easier to understand.
Expand Down Expand Up @@ -276,7 +276,7 @@ class Connection
}
Connection(EventLoop& loop,
kj::Own<kj::AsyncIoStream>&& stream_,
std::function<::capnp::Capability::Client(Connection&)> make_client)
const std::function<::capnp::Capability::Client(Connection&)>& make_client)
: m_loop(loop), m_stream(kj::mv(stream_)),
m_network(*m_stream, ::capnp::rpc::twoparty::Side::SERVER, ::capnp::ReaderOptions()),
m_rpc_system(::capnp::makeRpcServer(m_network, make_client(*this)))
Expand Down
2 changes: 1 addition & 1 deletion include/mp/proxy-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ decltype(auto) CustomReadField(TypeList<LocalType>,
InvokeContext& invoke_context,
Input&& input,
ReadDest&& read_dest,
typename std::enable_if<std::is_integral<LocalType>::value>::type* enable = 0)
typename std::enable_if<std::is_integral<LocalType>::value>::type* enable = nullptr)
{
auto value = input.get();
if (value < std::numeric_limits<LocalType>::min() || value > std::numeric_limits<LocalType>::max()) {
Expand Down
2 changes: 1 addition & 1 deletion include/mp/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ struct AsyncCallable
}
AsyncCallable(const AsyncCallable&) = default;
AsyncCallable(AsyncCallable&&) = default;
~AsyncCallable() noexcept {}
~AsyncCallable() noexcept = default;
ResultOf<Callable> operator()() const { return (m_callable->value)(); }
mutable std::shared_ptr<DestructorCatcher<Callable>> m_callable;
};
Expand Down
8 changes: 4 additions & 4 deletions src/mp/gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct Format
m_os << value;
return *this;
}
operator std::string() { return m_os.str(); }
operator std::string() const { return m_os.str(); }
std::ostringstream m_os;
};

Expand Down Expand Up @@ -149,7 +149,7 @@ void Generate(kj::StringPtr src_prefix,
}

std::string include_base = include_path;
std::string::size_type p = include_base.rfind(".");
std::string::size_type p = include_base.rfind('.');
if (p != std::string::npos) include_base.erase(p);

std::vector<std::string> args;
Expand Down Expand Up @@ -238,7 +238,7 @@ void Generate(kj::StringPtr src_prefix,
GetAnnotationText(file_schema.getProto(), NAMESPACE_ANNOTATION_ID, &message_namespace);

std::string base_name = include_base;
size_t output_slash = base_name.rfind("/");
size_t output_slash = base_name.rfind('/');
if (output_slash != std::string::npos) {
base_name.erase(0, output_slash + 1);
}
Expand Down Expand Up @@ -616,7 +616,7 @@ int main(int argc, char** argv)
auto cwd = fs->getCurrentPath();
#endif
for (size_t i = 4; i < argc; ++i) {
import_paths.push_back(argv[i]);
import_paths.emplace_back(argv[i]);
}
for (const char* path : {CMAKE_INSTALL_PREFIX "/include", capnp_PREFIX "/include"}) {
#ifdef HAVE_KJ_FILESYSTEM
Expand Down
2 changes: 1 addition & 1 deletion src/mp/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void EventLoop::removeClient(std::unique_lock<std::mutex>& lock)
m_cv.notify_all();
Unlock(lock, [&] {
char buffer = 0;
KJ_SYSCALL(write(m_post_fd, &buffer, 1));
KJ_SYSCALL(write(m_post_fd, &buffer, 1)); // NOLINT(bugprone-suspicious-semicolon)
});
}
}
Expand Down
1 change: 1 addition & 0 deletions src/mp/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ int SpawnProcess(int& pid, FdToArgsFn&& fd_to_args)
void ExecProcess(const std::vector<std::string>& args)
{
std::vector<char*> argv;
argv.reserve(args.size());
for (const auto& arg : args) {
argv.push_back(const_cast<char*>(arg.c_str()));
}
Expand Down
2 changes: 1 addition & 1 deletion test/mp/test/foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FooImplementation
void initThreadMap() {}
int callback(FooCallback& callback, int arg) { return callback.call(arg); }
int callbackUnique(std::unique_ptr<FooCallback> callback, int arg) { return callback->call(arg); }
int callbackShared(std::shared_ptr<FooCallback> callback, int arg) { return callback->call(arg); }
int callbackShared(std::shared_ptr<FooCallback> callback, int arg) { return callback->call(arg); } // NOLINT(performance-unnecessary-value-param)
Copy link
Collaborator

Choose a reason for hiding this comment

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

In commit "clang-tidy: Fix performance-unnecessary-value-param check" (0498ed8)

Note: I think it does make sense to suppress this lint warning than try to avoid it. Could potentially avoid it by changing this argument to const shared_ptr but there's currently no IPC serialization code to handle const shared_ptr only shared_ptr, so it does't compile. Also I don't think it would make sense to add const shared_ptr serialization code because most cases where you would pass const shared<ptr> it probably makes more sense to pass a plain const reference.

void saveCallback(std::shared_ptr<FooCallback> callback) { m_callback = std::move(callback); }
int callbackSaved(int arg) { return m_callback->call(arg); }
int callbackExtended(ExtendedCallback& callback, int arg) { return callback.callExtended(arg); }
Expand Down