Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
jll63 committed Sep 1, 2024
1 parent d8b7f64 commit 03090a4
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 55 deletions.
3 changes: 1 addition & 2 deletions examples/generator/animals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ struct Cat : Animal {
};

declare_method(void, kick, (virtual_ptr<Animal>));
declare_method(
void, meet, (virtual_ptr<Animal>, virtual_ptr<Animal>));
declare_method(void, meet, (virtual_ptr<Animal>, virtual_ptr<Animal>));

#if __has_include("slots.hpp")
#include "slots.hpp"
Expand Down
21 changes: 10 additions & 11 deletions examples/generator/generator_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@
void call_vf(Animal& a) {
// yardstick
a.kick();
// mov rax, qword ptr [rdi]
// jmp qword ptr [rax + 16] # TAILCALL
// mov rax, qword ptr [rdi]
// jmp qword ptr [rax + 16] # TAILCALL
}

void call_kick(virtual_ptr<Animal> animal) {
kick(animal);
// mov rax, qword ptr [rsi + 16]
// jmp rax # TAILCALL
// mov rax, qword ptr [rsi + 16]
// jmp rax # TAILCALL
}


void call_meet(virtual_ptr<Animal> a1, virtual_ptr<Animal> a2) {
meet(a1, a2);
// mov rax, qword ptr [rsi]
// mov r8, qword ptr [rcx + 8]
// lea r8, [r8 + 2*r8]
// mov rax, qword ptr [rax + 8*r8]
// jmp rax # TAILCALL
// mov rax, qword ptr [rsi]
// mov r8, qword ptr [rcx + 8]
// lea r8, [r8 + 2*r8]
// mov rax, qword ptr [rax + 8*r8]
// jmp rax # TAILCALL
}

int main() {
using namespace yorel::yomm2;

#include "tables.hpp"
#include "tables.hpp"

Cat felix;
auto cat = virtual_ptr<Cat>::final(felix);
Expand Down
7 changes: 0 additions & 7 deletions examples/vcpkg/README.md

This file was deleted.

3 changes: 1 addition & 2 deletions include/yorel/yomm2/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ class virtual_ptr {
Policy, Other&>::polymorphic_type>;
} else {
vptr = Policy::template static_vptr<
typename virtual_traits<
Policy, Other&>::polymorphic_type>;
typename virtual_traits<Policy, Other&>::polymorphic_type>;
}
} else {
auto index = dynamic_id;
Expand Down
3 changes: 1 addition & 2 deletions include/yorel/yomm2/detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,7 @@ auto& operator<<(
}

template<class Policy>
auto& operator<<(
trace_type<Policy>& trace, const range<type_id*>& tips) {
auto& operator<<(trace_type<Policy>& trace, const range<type_id*>& tips) {
return write_range(trace, tips, [](auto tip) { return type_name(tip); });
}

Expand Down
4 changes: 1 addition & 3 deletions include/yorel/yomm2/detail/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ void compiler<Policy>::resolve_static_type_ids() {
resolve(&ci.type);

if (*ci.last_base == 0) {
for (auto& ti :
range{ci.first_base, ci.last_base}) {
for (auto& ti : range{ci.first_base, ci.last_base}) {
resolve(&ti);
}

Expand Down Expand Up @@ -593,7 +592,6 @@ void compiler<Policy>::augment_methods() {
}
}


template<class Policy>
void compiler<Policy>::assign_slots() {
++trace << "Allocating slots...\n";
Expand Down
8 changes: 3 additions & 5 deletions include/yorel/yomm2/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@
#endif

#define YOMM2_DECLARE_3(R, ID, ARGS) \
yOMM2_DECLARE( \
R, ID, ARGS, YOMM2_DEFAULT_POLICY, yOMM2_WHEN_NOT_STATIC)
yOMM2_DECLARE(R, ID, ARGS, YOMM2_DEFAULT_POLICY, yOMM2_WHEN_NOT_STATIC)

#define YOMM2_DECLARE_4(R, ID, ARGS, POLICY) \
yOMM2_DECLARE(R, ID, ARGS, POLICY, yOMM2_WHEN_NOT_STATIC)

#define YOMM2_STATIC_DECLARE_3(R, ID, ARGS) \
yOMM2_DECLARE( \
R, ID, ARGS, YOMM2_DEFAULT_POLICY, yOMM2_WHEN_STATIC)
yOMM2_DECLARE(R, ID, ARGS, YOMM2_DEFAULT_POLICY, yOMM2_WHEN_STATIC)

#define YOMM2_STATIC_DECLARE_4(R, ID, ARGS, POLICY) \
yOMM2_DECLARE(R, ID, ARGS, POLICY, yOMM2_WHEN_STATIC)
Expand Down Expand Up @@ -215,7 +213,7 @@

#define YOMM2_CLASSES(...) \
static ::yorel::yomm2::detail::use_classes_macro< \
__VA_ARGS__, YOMM2_DEFAULT_POLICY> \
__VA_ARGS__, YOMM2_DEFAULT_POLICY> \
YOMM2_GENSYM;

#if !BOOST_PP_VARIADICS_MSVC
Expand Down
4 changes: 2 additions & 2 deletions src/yomm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ template class yOMM2_API_msc basic_policy<
template auto yOMM2_API_gcc yOMM2_API_msc update<policy::debug_shared>()
-> detail::compiler<policy::debug_shared>;

yOMM2_API_gcc yOMM2_API_msc auto update()
-> detail::compiler<policy::debug_shared> {
yOMM2_API_gcc yOMM2_API_msc auto
update() -> detail::compiler<policy::debug_shared> {
return update<policy::debug_shared>();
}

Expand Down
11 changes: 6 additions & 5 deletions tests/benchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ int main() {

#if __has_include(<boost/unordered/unordered_flat_map.hpp>)
#include <boost/unordered/unordered_flat_map.hpp>
#define UNORDERED_FLAT_MAP_AVAILABLE __has_include(<boost/unordered/unordered_flat_map.hpp>)
#define UNORDERED_FLAT_MAP_AVAILABLE \
__has_include(<boost/unordered/unordered_flat_map.hpp>)
#endif

#include <benchmark/benchmark.h>
Expand All @@ -44,9 +45,9 @@ enum { NH = YOMM2_BENCHMARK_HIERARCHIES };
enum { NH = 100 };
#endif

#define mb() asm volatile("mfence":::"memory")
#define rmb() asm volatile("lfence":::"memory")
#define wmb() asm volatile("sfence" ::: "memory")
#define mb() asm volatile("mfence" ::: "memory")
#define rmb() asm volatile("lfence" ::: "memory")
#define wmb() asm volatile("sfence" ::: "memory")

const std::string yomm2_ = "yomm2_";

Expand Down Expand Up @@ -668,7 +669,7 @@ int main(int argc, char** argv) {
#if !defined(NDEBUG)
mp_for_each<dispatch_types>([](auto D_value) {
using Dispatch = decltype(D_value);
if constexpr (true ||!std::is_same_v<Dispatch, no_dispatch>) {
if constexpr (true || !std::is_same_v<Dispatch, no_dispatch>) {
mp_for_each<arity_types>([](auto A_value) {
using Arity = decltype(A_value);
mp_for_each<inheritance_types>([](auto I_value) {
Expand Down
3 changes: 2 additions & 1 deletion tests/blackbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ YOMM2_DEFINE(void, times, (const diagonal_matrix&, const matrix&)) {
YOMM2_DEFINE(void, times, (const matrix&, const diagonal_matrix&)) {
}

void deprecated_test_handler(const method_call_error& error, std::size_t, type_id*) {
void deprecated_test_handler(
const method_call_error& error, std::size_t, type_id*) {
throw error;
}

Expand Down
1 change: 0 additions & 1 deletion tests/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ BOOST_AUTO_TEST_CASE(test_list) {
// a b c
BOOST_TEST_REQUIRE(std::distance(l.begin(), l.end()) == 3);


// test remove from back, the most common case
l.remove(c);
// a b
Expand Down
9 changes: 5 additions & 4 deletions tests/rdtsc-benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct Cat : Animal {
yomm2_vptr = intrusive::static_vptr<Cat>;
}

void pet_vf() override{/*purr*/};
void pet_vf() override { /*purr*/ };
};

struct YOMM2_SYMBOL(pet_ref);
Expand All @@ -83,16 +83,17 @@ struct Cat : Animal {
yomm2_vptr = intrusive::static_vptr<Cat>;
}

void pet_vf() override{/*purr*/};
void pet_vf() override { /*purr*/ };
};

} // namespace dyn

template<class Policy>
struct use_policy {
use_policy() {
YOMM2_STATIC(use_classes<
dyn::Animal, dyn::Cat, stat::Animal, stat::Cat, Policy>);
YOMM2_STATIC(
use_classes<
dyn::Animal, dyn::Cat, stat::Animal, stat::Cat, Policy>);
update<Policy>();
}
};
Expand Down
7 changes: 4 additions & 3 deletions tests/test_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ static_assert(
detail::has_static_offsets<method_class(
void, meet,
(virtual_<Animal&>, virtual_<Animal&>, std::ostream&))>::value);
static_assert(detail::has_static_offsets<method_class(
void, identify, (virtual_<Property&>, std::ostream&))>::value);
static_assert(
detail::has_static_offsets<method_class(
void, identify, (virtual_<Property&>, std::ostream&))>::value);

#define BOOST_TEST_MODULE test_generator
#include <boost/test/included/unit_test.hpp>
Expand All @@ -26,7 +27,7 @@ static_assert(detail::has_static_offsets<method_class(
using namespace yorel::yomm2;

BOOST_AUTO_TEST_CASE(test_generator) {
#include "test_generator_tables.hpp"
#include "test_generator_tables.hpp"

std::ostringstream os;

Expand Down
1 change: 0 additions & 1 deletion tests/test_generator_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ define_method(void, meet, (Dog&, Cat&, std::ostream& os)) {
os << "chase";
}


define_method(void, identify, (DomesticCat & animal, std::ostream& os)) {
os << animal.owner << "'s"
<< " cat";
Expand Down
3 changes: 1 addition & 2 deletions tests/test_generator_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)


#include "test_generator_domain.hpp"

#include <iostream>
Expand All @@ -19,7 +18,7 @@ int main(int argc, char* argv[]) {
#ifndef _MSC_VER
generator.add_forward_declarations().write_forward_declarations(slots);
#endif
generator.write_static_offsets(slots);
generator.write_static_offsets(slots);

std::ofstream tables("test_generator_tables.hpp");
generator.encode_dispatch_data(compiler, tables);
Expand Down
16 changes: 12 additions & 4 deletions tests/test_virtual_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ BOOST_AUTO_TEST_CASE(test_virtual_ptr_basic) {
virtual_ptr<Animal> const_upcast_copy(p);
}

{ auto p = virtual_ptr<const Animal>(dog); }
{
auto p = virtual_ptr<const Animal>(dog);
}

// should not compile
#ifdef YOMM2_SHOULD_NOT_COMPILE
{ auto vptr = virtual_ptr<Dog>(Dog()); }
{
auto vptr = virtual_ptr<Dog>(Dog());
}
#endif
}

Expand All @@ -74,9 +78,13 @@ BOOST_AUTO_TEST_CASE(test_virtual_ptr_basic) {
virtual_shared_ptr<Animal> upcast_copy(p);
}

{ auto p = virtual_shared_ptr<Dog>(std::make_shared<Dog>()); }
{
auto p = virtual_shared_ptr<Dog>(std::make_shared<Dog>());
}

{ auto p = virtual_shared_ptr<Animal>(std::make_shared<Dog>()); }
{
auto p = virtual_shared_ptr<Animal>(std::make_shared<Dog>());
}
}

{
Expand Down

0 comments on commit 03090a4

Please sign in to comment.