Skip to content

Commit

Permalink
Apply more clang-tidy fixes (#2763)
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers authored Oct 27, 2024
1 parent 458eff1 commit 90a798b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ Checks: [
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix,
-readability-use-anyofallof,
-modernize-loop-convert # since C++20 this complains about reverse loops with iterators, but good ranges support only landed in clang 15
-modernize-loop-convert, # since C++20 this complains about reverse loops with iterators, but good ranges support only landed in clang 15
-performance-enum-size,
-misc-include-cleaner,
-readability-redundant-inline-specifier,
-readability-avoid-nested-conditional-operator
]
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
Expand Down
6 changes: 4 additions & 2 deletions include/mbgl/gfx/shader_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ class ShaderGroup {
/// @tparam T Derived type, inheriting `gfx::Shader`
/// @param to Location to store the shader
/// @return True if 'to' has a valid program object, false otherwise.
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
bool populate(std::shared_ptr<T>& to) noexcept {
template <typename T>
bool populate(std::shared_ptr<T>& to) noexcept
requires(is_shader_v<T>)
{
if (to) {
return true;
}
Expand Down
9 changes: 6 additions & 3 deletions include/mbgl/gfx/vertex_attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,15 @@ class VertexAttribute {
}

template <std::size_t I = 0, typename... Tp>
inline typename std::enable_if_t<I == sizeof...(Tp), void> set(std::size_t, std::tuple<Tp...>, std::size_t) {}
inline void set(std::size_t, std::tuple<Tp...>, std::size_t)
requires(I == sizeof...(Tp))
{}

/// Set item value
template <std::size_t I = 0, typename... Tp>
inline typename std::enable_if_t <
I<sizeof...(Tp), void> set(std::size_t i, std::tuple<Tp...> tuple, std::size_t tupleIndex) {
inline void set(std::size_t i, std::tuple<Tp...> tuple, std::size_t tupleIndex)
requires(I < sizeof...(Tp))
{
if (tupleIndex == 0) {
set(i, std::get<I>(tuple).a1);
} else {
Expand Down
4 changes: 4 additions & 0 deletions include/mbgl/util/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ inline std::string toString(uint8_t t) {
return toString(static_cast<uint32_t>(t));
}

// NOLINTBEGIN(bugprone-incorrect-enable-if)

template <typename = std::enable_if<!std::is_same_v<uint64_t, unsigned long>>>
inline std::string toString(unsigned long t) {
return toString(static_cast<uint64_t>(t));
Expand All @@ -70,6 +72,8 @@ inline std::string toString(long long t) {
return toString(static_cast<int64_t>(t));
}

// NOLINTEND(bugprone-incorrect-enable-if)

inline std::string toString(float t, bool decimal = false) {
return toString(static_cast<double>(t), decimal);
}
Expand Down

0 comments on commit 90a798b

Please sign in to comment.