-
Notifications
You must be signed in to change notification settings - Fork 29
clang-tidy: fix warnings introduced in version 19 #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,20 +37,45 @@ struct StructField | |
} | ||
Struct& m_struct; | ||
|
||
// clang-format off | ||
template<typename A = Accessor> auto get() const -> decltype(A::get(this->m_struct)) { return A::get(this->m_struct); } | ||
template<typename A = Accessor> auto has() const -> std::enable_if_t<A::optional, bool> { return A::getHas(m_struct); } | ||
template<typename A = Accessor> auto has() const -> std::enable_if_t<!A::optional && A::boxed, bool> { return A::has(m_struct); } | ||
template<typename A = Accessor> auto has() const -> std::enable_if_t<!A::optional && !A::boxed, bool> { return true; } | ||
template<typename A = Accessor> auto want() const -> std::enable_if_t<A::requested, bool> { return A::getWant(m_struct); } | ||
template<typename A = Accessor> auto want() const -> std::enable_if_t<!A::requested, bool> { return true; } | ||
template<typename A = Accessor, typename... Args> decltype(auto) set(Args&&... args) const { return A::set(this->m_struct, std::forward<Args>(args)...); } | ||
template<typename A = Accessor, typename... Args> decltype(auto) init(Args&&... args) const { return A::init(this->m_struct, std::forward<Args>(args)...); } | ||
template<typename A = Accessor> auto setHas() const -> std::enable_if_t<A::optional> { return A::setHas(m_struct); } | ||
template<typename A = Accessor> auto setHas() const -> std::enable_if_t<!A::optional> { } | ||
template<typename A = Accessor> auto setWant() const -> std::enable_if_t<A::requested> { return A::setWant(m_struct); } | ||
template<typename A = Accessor> auto setWant() const -> std::enable_if_t<!A::requested> { } | ||
// clang-format on | ||
decltype(auto) get() const { return Accessor::get(this->m_struct); } | ||
|
||
bool has() const { | ||
if constexpr (Accessor::optional) { | ||
return Accessor::getHas(m_struct); | ||
} else if constexpr (Accessor::boxed) { | ||
return Accessor::has(m_struct); | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
bool want() const { | ||
if constexpr (Accessor::requested) { | ||
return Accessor::getWant(m_struct); | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
template <typename... Args> decltype(auto) set(Args &&...args) const { | ||
return Accessor::set(this->m_struct, std::forward<Args>(args)...); | ||
} | ||
|
||
template <typename... Args> decltype(auto) init(Args &&...args) const { | ||
return Accessor::init(this->m_struct, std::forward<Args>(args)...); | ||
} | ||
|
||
void setHas() const { | ||
if constexpr (Accessor::optional) { | ||
Accessor::setHas(m_struct); | ||
} | ||
} | ||
|
||
void setWant() const { | ||
if constexpr (Accessor::requested) { | ||
Accessor::setWant(m_struct); | ||
} | ||
} | ||
}; | ||
|
||
|
||
|
@@ -364,30 +389,17 @@ struct ClientParam | |
|
||
struct BuildParams : IterateFieldsHelper<BuildParams, sizeof...(Types)> | ||
{ | ||
template <typename... Args> | ||
void handleField(Args&&... args) | ||
{ | ||
callBuild<0>(std::forward<Args>(args)...); | ||
} | ||
|
||
// TODO Possible optimization to speed up compile time: | ||
// https://stackoverflow.com/a/7858971 Using enable_if below to check | ||
// position when unpacking tuple might be slower than pattern matching | ||
// approach in the stack overflow solution | ||
template <size_t I, typename... Args> | ||
auto callBuild(Args&&... args) -> std::enable_if_t<(I < sizeof...(Types))> | ||
{ | ||
callBuild<I + 1>(std::forward<Args>(args)..., std::get<I>(m_client_param->m_values)); | ||
} | ||
|
||
template <size_t I, typename Params, typename ParamList, typename... Values> | ||
auto callBuild(ClientInvokeContext& invoke_context, Params& params, ParamList, Values&&... values) -> | ||
std::enable_if_t<(I == sizeof...(Types))> | ||
template <typename Params, typename ParamList> | ||
void handleField(ClientInvokeContext& invoke_context, Params& params, ParamList) | ||
{ | ||
MaybeBuildField(std::integral_constant<bool, Accessor::in>(), ParamList(), invoke_context, | ||
Make<StructField, Accessor>(params), std::forward<Values>(values)...); | ||
MaybeSetWant( | ||
ParamList(), Priority<1>(), std::forward<Values>(values)..., Make<StructField, Accessor>(params)); | ||
auto const fun = [&]<typename... Values>(Values&&... values) { | ||
ryanofsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MaybeBuildField(std::integral_constant<bool, Accessor::in>(), ParamList(), invoke_context, | ||
Make<StructField, Accessor>(params), std::forward<Values>(values)...); | ||
MaybeSetWant( | ||
ParamList(), Priority<1>(), std::forward<Values>(values)..., Make<StructField, Accessor>(params)); | ||
}; | ||
|
||
std::apply(fun, m_client_param->m_values); | ||
} | ||
|
||
BuildParams(ClientParam* client_param) : m_client_param(client_param) {} | ||
|
@@ -396,24 +408,15 @@ struct ClientParam | |
|
||
struct ReadResults : IterateFieldsHelper<ReadResults, sizeof...(Types)> | ||
{ | ||
template <typename... Args> | ||
void handleField(Args&&... args) | ||
template <typename Results, typename... Params> | ||
void handleField(ClientInvokeContext& invoke_context, Results& results, TypeList<Params...>) | ||
{ | ||
callRead<0>(std::forward<Args>(args)...); | ||
} | ||
auto const fun = [&]<typename... Values>(Values&&... values) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In commit "replace custom tuple unpacking code with Note: In general there are a lot more simplifications that can be made here now that this code no longer needs to work with c++11. Would be good to follow up in a separate PR. |
||
MaybeReadField(std::integral_constant<bool, Accessor::out>(), TypeList<Decay<Params>...>(), invoke_context, | ||
Make<StructField, Accessor>(results), ReadDestUpdate(values)...); | ||
}; | ||
|
||
template <int I, typename... Args> | ||
auto callRead(Args&&... args) -> std::enable_if_t<(I < sizeof...(Types))> | ||
{ | ||
callRead<I + 1>(std::forward<Args>(args)..., std::get<I>(m_client_param->m_values)); | ||
} | ||
|
||
template <int I, typename Results, typename... Params, typename... Values> | ||
auto callRead(ClientInvokeContext& invoke_context, Results& results, TypeList<Params...>, Values&&... values) | ||
-> std::enable_if_t<I == sizeof...(Types)> | ||
{ | ||
MaybeReadField(std::integral_constant<bool, Accessor::out>(), TypeList<Decay<Params>...>(), invoke_context, | ||
Make<StructField, Accessor>(results), ReadDestUpdate(values)...); | ||
std::apply(fun, m_client_param->m_values); | ||
} | ||
|
||
ReadResults(ClientParam* client_param) : m_client_param(client_param) {} | ||
|
@@ -650,19 +653,14 @@ void clientInvoke(ProxyClient& proxy_client, const GetRequest& get_request, Fiel | |
//! return value with value of `ret()`. This is useful for avoiding code | ||
//! duplication and branching in generic code that forwards calls to functions. | ||
template <typename Fn, typename Ret> | ||
auto ReplaceVoid(Fn&& fn, Ret&& ret) -> | ||
std::enable_if_t<std::is_same_v<void, decltype(fn())>, decltype(ret())> | ||
auto ReplaceVoid(Fn&& fn, Ret&& ret) | ||
{ | ||
fn(); | ||
return ret(); | ||
} | ||
|
||
//! Overload of above for non-void `fn()` case. | ||
template <typename Fn, typename Ret> | ||
auto ReplaceVoid(Fn&& fn, Ret&& ret) -> | ||
std::enable_if_t<!std::is_same_v<void, decltype(fn())>, decltype(fn())> | ||
{ | ||
return fn(); | ||
if constexpr (std::is_same_v<decltype(fn()), void>) { | ||
fn(); | ||
return ret(); | ||
} else { | ||
return fn(); | ||
} | ||
} | ||
|
||
extern std::atomic<int> server_reqs; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "replace SFINAE trick with
if constexpr
" (8ed7b63)Seems like good changes, but is indentation in this part of the code supposed to use 4 spaces instead of 2? Would be good to make this consistent and maybe use clang-format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great if there was a
.clang-format
file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #165 (comment)
Note: Spacing is still not consistent, but should be fine to reformat later.