From 5e19e6454d59dd71f8f7eeb73e5d7108a7a2de8f Mon Sep 17 00:00:00 2001 From: rise Date: Mon, 11 May 2020 13:53:43 +0800 Subject: [PATCH] fix use clang build nullptr_t error --- include/eosio/vm/backend.hpp | 8 ++++---- include/eosio/vm/host_function.hpp | 6 +++--- include/eosio/vm/wasm_stack.hpp | 10 +++++----- tools/bench_interp.cpp | 2 +- tools/hello_driver.cpp | 6 +++--- tools/interp.cpp | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/eosio/vm/backend.hpp b/include/eosio/vm/backend.hpp index 9af83eda..a9554eaa 100644 --- a/include/eosio/vm/backend.hpp +++ b/include/eosio/vm/backend.hpp @@ -42,15 +42,15 @@ namespace eosio { namespace vm { public: using host_t = Host; - template + template backend(wasm_code& code, HostFunctions = nullptr) : _ctx(typename Impl::template parser{ _mod.allocator }.parse_module(code, _mod)) { - if constexpr (!std::is_same_v) + if constexpr (!std::is_same_v) HostFunctions::resolve(_mod); _mod.finalize(); } - template + template backend(wasm_code_ptr& ptr, size_t sz, HostFunctions = nullptr) : _ctx(typename Impl::template parser{ _mod.allocator }.parse_module2(ptr, sz, _mod)) { - if constexpr (!std::is_same_v) + if constexpr (!std::is_same_v) HostFunctions::resolve(_mod); _mod.finalize(); } diff --git a/include/eosio/vm/host_function.hpp b/include/eosio/vm/host_function.hpp index 00c3e255..7c37c6c4 100644 --- a/include/eosio/vm/host_function.hpp +++ b/include/eosio/vm/host_function.hpp @@ -32,8 +32,8 @@ namespace eosio { namespace vm { }; template - struct construct_derived { - static nullptr_t value(nullptr_t) { return nullptr; } + struct construct_derived { + static std::nullptr_t value(std::nullptr_t) { return nullptr; } }; // Workaround for compiler bug handling C++g17 auto template parameters. @@ -466,7 +466,7 @@ namespace eosio { namespace vm { template decltype(auto) invoke_with_host(Host* host, T&&... args) { - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) return std::invoke(F, static_cast(args)...); else return std::invoke(F, construct_derived::value(*host), static_cast(args)...); diff --git a/include/eosio/vm/wasm_stack.hpp b/include/eosio/vm/wasm_stack.hpp index 1de06e4f..df009b86 100644 --- a/include/eosio/vm/wasm_stack.hpp +++ b/include/eosio/vm/wasm_stack.hpp @@ -12,19 +12,19 @@ #include namespace eosio { namespace vm { - template + template class stack { public: - template , int>> + template , int>> stack() : _store(ElemSz) {} - template , int>> + template , int>> stack(Alloc&& alloc) : _store(alloc, ElemSz) {} void push(ElemT&& e) { - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { if (_index >= _store.size()) _store.resize(_store.size()*2); } @@ -56,7 +56,7 @@ namespace eosio { namespace vm { size_t size() const { return _index; } private: - using base_data_store_t = std::conditional_t, unmanaged_vector, managed_vector>; + using base_data_store_t = std::conditional_t, unmanaged_vector, managed_vector>; base_data_store_t _store; size_t _index = 0; diff --git a/tools/bench_interp.cpp b/tools/bench_interp.cpp index b2e19d00..2197a6ce 100644 --- a/tools/bench_interp.cpp +++ b/tools/bench_interp.cpp @@ -10,7 +10,7 @@ using namespace eosio::vm; int main(int argc, char** argv) { wasm_allocator wa; - using backend_t = eosio::vm::backend; + using backend_t = eosio::vm::backend; if (argc < 2) { std::cerr << "Error, no wasm file provided\n"; diff --git a/tools/hello_driver.cpp b/tools/hello_driver.cpp index d0b0377d..54face84 100644 --- a/tools/hello_driver.cpp +++ b/tools/hello_driver.cpp @@ -52,13 +52,13 @@ int main(int argc, char** argv) { using rhf_t = eosio::vm::registered_host_functions; // register print_num - rhf_t::add("env", "print_num"); + rhf_t::add("env", "print_num"); // register eosio_assert - rhf_t::add("env", "eosio_assert"); + rhf_t::add("env", "eosio_assert"); // register print_name rhf_t::add("env", "print_name"); // finally register memset - rhf_t::add("env", "memset"); + rhf_t::add("env", "memset"); watchdog wd{std::chrono::seconds(3)}; try { diff --git a/tools/interp.cpp b/tools/interp.cpp index e4f2330e..c2a31226 100644 --- a/tools/interp.cpp +++ b/tools/interp.cpp @@ -14,7 +14,7 @@ int main(int argc, char** argv) { // Thread specific `allocator` used for wasm linear memory. wasm_allocator wa; // Specific the backend with no "host" for host functions. - using backend_t = eosio::vm::backend; + using backend_t = eosio::vm::backend; if (argc < 2) { std::cerr << "Error, no wasm file provided\n";