Skip to content
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

Reformat code according to clang-format-15 #4938

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^<(BeastConfig)'
Priority: 0
- Regex: '^<(ripple)/'
Priority: 2
- Regex: '^<(boost)/'
Expand All @@ -56,6 +54,7 @@ IncludeCategories:
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: false
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
Expand All @@ -71,6 +70,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
RequiresClausePosition: OwnLine
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
Expand Down
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# To use it by default in git blame:
# git config blame.ignoreRevsFile .git-blame-ignore-revs
50760c693510894ca368e90369b0cc2dabfd07f3
27917f71f312182685963f79db2204df16c68e9e
12 changes: 5 additions & 7 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
CLANG_VERSION: 10
CLANG_VERSION: 15
steps:
- uses: actions/checkout@v3
- name: Install clang-format
Expand All @@ -19,10 +19,8 @@ jobs:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add
sudo apt-get update
sudo apt-get install clang-format-${CLANG_VERSION}
- name: Format src/ripple
run: find src/ripple -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i
- name: Format src/test
run: find src/test -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i
- name: Format first-party sources
run: find src/ripple src/test -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i
- name: Check for differences
id: assert
run: |
Expand Down Expand Up @@ -52,7 +50,7 @@ jobs:
To fix it, you can do one of two things:
1. Download and apply the patch generated as an artifact of this
job to your repo, commit, and push.
2. Run 'git-clang-format --extensions c,cpp,h,cxx,ipp develop'
2. Run 'git-clang-format --extensions cpp,h,hpp,ipp develop'
in your repo, commit, and push.
run: |
echo "${PREAMBLE}"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v10.0.1
rev: v15.0.7
hooks:
- id: clang-format
3 changes: 1 addition & 2 deletions src/ripple/app/misc/impl/ValidatorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,7 @@ ValidatorList::sendValidatorList(
beast::Journal j)
{
std::size_t const messageVersion =
peer.supportsFeature(ProtocolFeature::ValidatorList2Propagation)
? 2
peer.supportsFeature(ProtocolFeature::ValidatorList2Propagation) ? 2
: peer.supportsFeature(ProtocolFeature::ValidatorListPropagation) ? 1
: 0;
if (!messageVersion)
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/paths/impl/DirectStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ class DirectIPaymentStep : public DirectStepI<DirectIPaymentStep>
using DirectStepI<DirectIPaymentStep>::DirectStepI;
using DirectStepI<DirectIPaymentStep>::check;

bool verifyPrevStepDebtDirection(DebtDirection) const
bool
verifyPrevStepDebtDirection(DebtDirection) const
{
// A payment doesn't care whether or not prevStepRedeems.
return true;
Expand Down
47 changes: 28 additions & 19 deletions src/ripple/basics/Expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,39 +136,43 @@ class [[nodiscard]] Expected

public:
template <typename U>
requires std::convertible_to<U, T> constexpr Expected(U && r)
: Base(T(std::forward<U>(r)))
requires std::convertible_to<U, T>
constexpr Expected(U&& r) : Base(T(std::forward<U>(r)))
{
}

template <typename U>
requires std::convertible_to<U, E> &&
(!std::is_reference_v<U>)constexpr Expected(Unexpected<U> e)
: Base(E(std::move(e.value())))
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
constexpr Expected(Unexpected<U> e) : Base(E(std::move(e.value())))
{
}

constexpr bool has_value() const
constexpr bool
has_value() const
{
return Base::has_value();
}

constexpr T const& value() const
constexpr T const&
value() const
{
return Base::value();
}

constexpr T& value()
constexpr T&
value()
{
return Base::value();
}

constexpr E const& error() const
constexpr E const&
error() const
{
return Base::error();
}

constexpr E& error()
constexpr E&
error()
{
return Base::error();
}
Expand All @@ -181,22 +185,26 @@ class [[nodiscard]] Expected
// Add operator* and operator-> so the Expected API looks a bit more like
// what std::expected is likely to look like. See:
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html
[[nodiscard]] constexpr T& operator*()
[[nodiscard]] constexpr T&
operator*()
{
return this->value();
}

[[nodiscard]] constexpr T const& operator*() const
[[nodiscard]] constexpr T const&
operator*() const
{
return this->value();
}

[[nodiscard]] constexpr T* operator->()
[[nodiscard]] constexpr T*
operator->()
{
return &this->value();
}

[[nodiscard]] constexpr T const* operator->() const
[[nodiscard]] constexpr T const*
operator->() const
{
return &this->value();
}
Expand All @@ -218,18 +226,19 @@ class [[nodiscard]] Expected<void, E>
}

template <typename U>
requires std::convertible_to<U, E> &&
(!std::is_reference_v<U>)constexpr Expected(Unexpected<U> e)
: Base(E(std::move(e.value())))
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
constexpr Expected(Unexpected<U> e) : Base(E(std::move(e.value())))
{
}

constexpr E const& error() const
constexpr E const&
error() const
{
return Base::error();
}

constexpr E& error()
constexpr E&
error()
{
return Base::error();
}
Expand Down
21 changes: 11 additions & 10 deletions src/ripple/basics/FeeUnits.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ class TaggedFee : private boost::totally_ordered<TaggedFee<UnitTag, T>>,
protected:
template <class Other>
static constexpr bool is_compatible_v =
std::is_arithmetic_v<Other>&& std::is_arithmetic_v<value_type>&&
std::is_convertible_v<Other, value_type>;
std::is_arithmetic_v<Other> && std::is_arithmetic_v<value_type> &&
std::is_convertible_v<Other, value_type>;

template <class OtherFee, class = enable_if_unit_t<OtherFee>>
static constexpr bool is_compatiblefee_v =
is_compatible_v<typename OtherFee::value_type>&&
std::is_same_v<UnitTag, typename OtherFee::unit_type>;
is_compatible_v<typename OtherFee::value_type> &&
std::is_same_v<UnitTag, typename OtherFee::unit_type>;

template <class Other>
using enable_if_compatible_t =
Expand All @@ -110,7 +110,8 @@ class TaggedFee : private boost::totally_ordered<TaggedFee<UnitTag, T>>,
{
}

constexpr TaggedFee& operator=(beast::Zero)
constexpr TaggedFee&
operator=(beast::Zero)
{
fee_ = 0;
return *this;
Expand Down Expand Up @@ -344,8 +345,8 @@ constexpr bool can_muldiv_source_v =

template <class Dest, class = enable_if_unit_t<Dest>>
constexpr bool can_muldiv_dest_v =
can_muldiv_source_v<Dest>&& // Dest is also a source
std::is_convertible_v<std::uint64_t, typename Dest::value_type> &&
can_muldiv_source_v<Dest> && // Dest is also a source
std::is_convertible_v<std::uint64_t, typename Dest::value_type> &&
sizeof(typename Dest::value_type) >= sizeof(std::uint64_t);

template <
Expand All @@ -354,8 +355,8 @@ template <
class = enable_if_unit_t<Source1>,
class = enable_if_unit_t<Source2>>
constexpr bool can_muldiv_sources_v =
can_muldiv_source_v<Source1>&& can_muldiv_source_v<Source2>&& std::
is_same_v<typename Source1::unit_type, typename Source2::unit_type>;
can_muldiv_source_v<Source1> && can_muldiv_source_v<Source2> &&
std::is_same_v<typename Source1::unit_type, typename Source2::unit_type>;

template <
class Source1,
Expand All @@ -365,7 +366,7 @@ template <
class = enable_if_unit_t<Source2>,
class = enable_if_unit_t<Dest>>
constexpr bool can_muldiv_v =
can_muldiv_sources_v<Source1, Source2>&& can_muldiv_dest_v<Dest>;
can_muldiv_sources_v<Source1, Source2> && can_muldiv_dest_v<Dest>;
// Source and Dest can be the same by default

template <
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/basics/IOUAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ inline IOUAmount::IOUAmount(std::int64_t mantissa, int exponent)
normalize();
}

inline IOUAmount& IOUAmount::operator=(beast::Zero)
inline IOUAmount&
IOUAmount::operator=(beast::Zero)
{
// The -100 is used to allow 0 to sort less than small positive values
// which will have a large negative exponent.
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/basics/XRPAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class XRPAmount : private boost::totally_ordered<XRPAmount>,
{
}

constexpr XRPAmount& operator=(beast::Zero)
constexpr XRPAmount&
operator=(beast::Zero)
{
drops_ = 0;
return *this;
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/basics/base_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ class base_uint
return bytes;
}

base_uint<Bits, Tag>& operator=(beast::Zero)
base_uint<Bits, Tag>&
operator=(beast::Zero)
{
data_.fill(0);
return *this;
Expand Down
6 changes: 4 additions & 2 deletions src/ripple/basics/impl/ResolverAsio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ class ResolverAsioImpl : public ResolverAsio,

//-------------------------------------------------------------------------
// Resolver
void do_stop(CompletionCounter)
void
do_stop(CompletionCounter)
{
assert(m_stop_called == true);

Expand Down Expand Up @@ -330,7 +331,8 @@ class ResolverAsioImpl : public ResolverAsio,
std::string(port_first, port_last));
}

void do_work(CompletionCounter)
void
do_work(CompletionCounter)
{
if (m_stop_called == true)
return;
Expand Down
12 changes: 8 additions & 4 deletions src/ripple/beast/insight/impl/NullCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class NullCounterImpl : public CounterImpl
public:
explicit NullCounterImpl() = default;

void increment(value_type) override
void
increment(value_type) override
{
}

Expand Down Expand Up @@ -74,11 +75,13 @@ class NullGaugeImpl : public GaugeImpl
public:
explicit NullGaugeImpl() = default;

void set(value_type) override
void
set(value_type) override
{
}

void increment(difference_type) override
void
increment(difference_type) override
{
}

Expand All @@ -94,7 +97,8 @@ class NullMeterImpl : public MeterImpl
public:
explicit NullMeterImpl() = default;

void increment(value_type) override
void
increment(value_type) override
{
}

Expand Down
Loading
Loading