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

WebAssembly/Clang Update #8

Closed
wants to merge 19 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
23 changes: 23 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Linux

on: [push]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_EXAMPLES=OFF -G Ninja

- name: Build
run: cmake --build ${{github.workspace}}/build

- name: Test
run: cmake --build ${{github.workspace}}/build --target run_tests
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.vscode
build
build*
15 changes: 15 additions & 0 deletions src/rttr/detail/base/core_prerequisites.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ namespace rttr
# define RTTR_END_DISABLE_OVERRIDE_WARNING
#endif

#if RTTR_COMP_VER >= 900
# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING _Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Winit-list-lifetime\"")
# define RTTR_END_DISABLE_INIT_LIST_WARNING _Pragma ("GCC diagnostic pop")
# else
# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
# define RTTR_END_DISABLE_INIT_LIST_WARNING
#endif

# define RTTR_DECLARE_PLUGIN_CTOR __attribute__((constructor))
# define RTTR_DECLARE_PLUGIN_DTOR __attribute__((destructor))

Expand Down Expand Up @@ -311,6 +320,10 @@ namespace rttr
# define RTTR_END_DISABLE_OVERRIDE_WARNING
#endif


# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
# define RTTR_END_DISABLE_INIT_LIST_WARNING

# define RTTR_DECLARE_PLUGIN_CTOR __attribute__((__constructor__))
# define RTTR_DECLARE_PLUGIN_DTOR __attribute__((__destructor__))

Expand All @@ -330,6 +343,8 @@ namespace rttr
# define RTTR_DECLARE_PLUGIN_DTOR
# define RTTR_BEGIN_DISABLE_OVERRIDE_WARNING
# define RTTR_END_DISABLE_OVERRIDE_WARNING
# define RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
# define RTTR_END_DISABLE_INIT_LIST_WARNING

#else
# pragma message("WARNING: unknown compiler, don't know how to disable deprecated warnings")
Expand Down
6 changes: 3 additions & 3 deletions src/rttr/detail/conversion/number_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ typename std::enable_if<std::is_floating_point<F>::value &&
bool>::type
convert_to(const F& from, T& to)
{
if (from > std::numeric_limits<T>::max())
if (from > static_cast<F>(std::numeric_limits<T>::max()))
return false; // value too large
else if (from < -std::numeric_limits<T>::max())
else if (from < static_cast<F>(-std::numeric_limits<T>::max()))
return false; // value to small

to = static_cast<T>(from);
Expand All @@ -151,7 +151,7 @@ typename std::enable_if<std::is_floating_point<F>::value &&
bool>::type
convert_to(const F& from, T& to)
{
if (from < 0 || from > std::numeric_limits<T>::max())
if (from < 0 || from > static_cast<F>(std::numeric_limits<T>::max()))
return false; // value too large

to = static_cast<T>(from);
Expand Down
76 changes: 34 additions & 42 deletions src/rttr/detail/registration/bind_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,10 @@ class registration::bind<detail::ctor_func, Class_Type, F, acc_level, Visitor_Li
(param_names_count<Args...>::value == function_traits<Acc_Func>::arg_count)),
"The provided amount of names in 'parameter_names' does not match argument count of the function signature.");

auto ctor = create_constructor_wrapper(func,
std::move(get_metadata(std::forward<Args>(args)...)),
std::move(get_default_args<type_list<Acc_Func>, function_type>(std::forward<Args>(args)...)),
std::move(create_param_infos<type_list<F>, function_type>(std::forward<Args>(args)...)));
return std::move(ctor);
return create_constructor_wrapper(func,
get_metadata(std::forward<Args>(args)...),
get_default_args<type_list<Acc_Func>, function_type>(std::forward<Args>(args)...),
create_param_infos<type_list<F>, function_type>(std::forward<Args>(args)...));
}
public:
bind(const std::shared_ptr<detail::registration_executer>& reg_exec, F func)
Expand Down Expand Up @@ -389,15 +388,14 @@ class registration::bind<detail::prop, Class_Type, A, acc_level, Visitor_List> :
using setter_policy = typename get_setter_policy<first_prop_policy>::type;
using acc_type = typename property_type<Acc>::type;

auto prop = detail::make_unique<property_wrapper<acc_type,
Class_Type,
Acc,
void,
detail::map_access_level_to_enum<acc_level>::value,
getter_policy, setter_policy,
Metadata_Count,
Visitor_List>>(name, acc, std::move(metadata_list));
return std::move(prop);
return detail::make_unique<property_wrapper<acc_type,
Class_Type,
Acc,
void,
detail::map_access_level_to_enum<acc_level>::value,
getter_policy, setter_policy,
Metadata_Count,
Visitor_List>>(name, acc, std::move(metadata_list));
}

public:
Expand Down Expand Up @@ -483,15 +481,14 @@ class registration::bind<detail::prop, Class_Type, A1, A2, acc_level, Visitor_Li
using getter_policy = typename get_getter_policy<first_prop_policy>::type;
using setter_policy = typename get_setter_policy<first_prop_policy>::type;
using acc_type = typename property_type<A1>::type;
auto prop = detail::make_unique<property_wrapper<acc_type,
Class_Type,
Acc1, Acc2,
detail::map_access_level_to_enum<acc_level>::value,
getter_policy, setter_policy,
Metadata_Count, Visitor_List
>
>(name, getter, setter, std::move(metadata_list));
return std::move(prop);
return detail::make_unique<property_wrapper<acc_type,
Class_Type,
Acc1, Acc2,
detail::map_access_level_to_enum<acc_level>::value,
getter_policy, setter_policy,
Metadata_Count, Visitor_List
>
>(name, getter, setter, std::move(metadata_list));
}

public:
Expand Down Expand Up @@ -577,13 +574,11 @@ class registration::bind<detail::prop_readonly, Class_Type, A, acc_level, Visito
using getter_policy = typename get_getter_policy<first_prop_policy>::type;
using acc_type = typename property_type<Acc>::type;

auto prop = detail::make_unique<property_wrapper<acc_type, Class_Type, Acc, void,
detail::map_access_level_to_enum<acc_level>::value,
getter_policy, default_setter_policy, Metadata_Count, Visitor_List
>
>(name, acc, std::move(metadata_list));

return std::move(prop);
return detail::make_unique<property_wrapper<acc_type, Class_Type, Acc, void,
detail::map_access_level_to_enum<acc_level>::value,
getter_policy, default_setter_policy, Metadata_Count, Visitor_List
>
>(name, acc, std::move(metadata_list));
}

public:
Expand Down Expand Up @@ -673,12 +668,11 @@ class registration::bind<detail::meth, Class_Type, F, acc_level, Visitor_List> :
policy_types_found>;
using policy = typename std::tuple_element<0, as_std_tuple_t<policy_list>>::type;
using metadata_count = count_type<::rttr::detail::metadata, type_list<Args...>>;
auto meth = create_method_wrapper<policy,
metadata_count::value>(name, func,
std::move(get_metadata(std::forward<Args>(args)...)),
std::move(get_default_args<type_list<Acc_Func>, function_type>(std::forward<Args>(args)...)),
std::move(create_param_infos<type_list<F>, function_type>(std::forward<Args>(args)...)) );
return std::move(meth);
return create_method_wrapper<policy,
metadata_count::value>(name, func,
get_metadata(std::forward<Args>(args)...),
get_default_args<type_list<Acc_Func>, function_type>(std::forward<Args>(args)...),
create_param_infos<type_list<F>, function_type>(std::forward<Args>(args)...) );
}

template<typename Policy, std::size_t Metadata_Count, typename...TArgs, typename...Param_Args>
Expand Down Expand Up @@ -785,13 +779,11 @@ class registration::bind<detail::enum_, Class_Type, Enum_Type> : public registra

using metadata_count = count_type<::rttr::detail::metadata, type_list<Args...>>;

auto enum_wrapper = detail::make_unique<enumeration_wrapper<E_Type,
enum_count,
metadata_count::value>>(get_enum_values<E_Type>(std::forward<Args>(args)...),
std::move(get_metadata(std::forward<Args>(args)...)));

return detail::make_unique<enumeration_wrapper<E_Type,
enum_count,
metadata_count::value>>(get_enum_values<E_Type>(std::forward<Args>(args)...),
get_metadata(std::forward<Args>(args)...));

return std::move(enum_wrapper);
}

public:
Expand Down
2 changes: 1 addition & 1 deletion src/rttr/detail/type/type_register.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class RTTR_API type_register

private:

friend class type;
friend class rttr::type;
template<typename T>
friend class class_;

Expand Down
20 changes: 16 additions & 4 deletions src/rttr/detail/variant/variant_data_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,25 @@ enable_if_t<is_wrapper<T>::value && !is_dereferenceable<Tp>::value, argument> ge
/////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
enable_if_t<!is_wrapper<T>::value &&
is_dereferenceable<T>::value, argument> get_reference_argument(T& value)
{
enable_if_t< !is_wrapper<T>::value && is_dereferenceable<T>::value &&
!std::is_void<typename std::remove_pointer<T>::type>::value, argument> get_reference_argument(T& value)
{
return argument(*value);
}

/////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
enable_if_t<!is_wrapper<T>::value && is_dereferenceable<T>::value &&
std::is_void<typename std::remove_pointer<T>::type>::value, argument> get_reference_argument(T& value)
{
// This is specifically for the scenario when T is void*. And since we cannot actually do anything
// meaningful with a void* variable we will just return an empty argument.
return argument();
}

/////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
enable_if_t<!is_wrapper<T>::value &&
!is_dereferenceable<T>::value, argument> get_reference_argument(T& value)
Expand Down Expand Up @@ -494,7 +505,7 @@ struct variant_data_policy_big : variant_data_base_policy<T, variant_data_policy
{
delete &value;
}

RTTR_BEGIN_DISABLE_INIT_LIST_WARNING
static RTTR_INLINE void clone(const T& value, variant_data& dest)
{
reinterpret_cast<T*&>(dest) = new T(value);
Expand All @@ -510,6 +521,7 @@ struct variant_data_policy_big : variant_data_base_policy<T, variant_data_policy
{
reinterpret_cast<T*&>(dest) = new T(std::forward<U>(value));
}
RTTR_END_DISABLE_INIT_LIST_WARNING
};

/////////////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions src/unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ set_target_properties(unit_tests PROPERTIES DEBUG_POSTFIX ${RTTR_DEBUG_POSTFIX}
set_compiler_warnings(unit_tests)

if (MSVC)
target_compile_options(unit_tests PRIVATE /bigobj)
target_compile_options(unit_tests PRIVATE /bigobj)
endif()

# run tests
add_custom_target(run_tests ALL
COMMAND "$<TARGET_FILE:unit_tests>"
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib "$<TARGET_FILE:unit_tests>"
DEPENDS unit_tests
COMMENT "Running unit_tests")
set_target_properties(run_tests PROPERTIES

set_target_properties(run_tests PROPERTIES
FOLDER "Testing")

add_subdirectory(plugin)
Expand Down
9 changes: 9 additions & 0 deletions src/unit_tests/variant/variant_assign_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ TEST_CASE("move assignment", "[variant]")

TEST_CASE("variant::operator=() - self assignment", "[variant]")
{
#if RTTR_COMPILER == RTTR_COMPILER_CLANG || RTTR_COMPILER == RTTR_COMPILER_APPLECLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wself-assign"
#endif

SECTION("self assign - empty")
{
variant a;
Expand All @@ -165,6 +170,10 @@ TEST_CASE("variant::operator=() - self assignment", "[variant]")

CHECK(a.is_valid() == true);
}

#if RTTR_COMPILER == RTTR_COMPILER_CLANG || RTTR_COMPILER == RTTR_COMPILER_APPLECLANG
#pragma clang diagnostic pop
#endif
}

/////////////////////////////////////////////////////////////////////////////////////////