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

Fix build issues related to clang 15 #659

Merged
merged 2 commits into from
Aug 3, 2022
Merged
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
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Checks: >
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-unchecked-optional-access,
cert-*,
-cert-err58-cpp,
clang-analyzer-*,
Expand Down
2 changes: 1 addition & 1 deletion examples/example_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
extern "C" {
#endif

const struct evmc_host_interface* example_host_get_interface();
const struct evmc_host_interface* example_host_get_interface(void);

struct evmc_host_context* example_host_create_context(struct evmc_tx_context tx_context);

Expand Down
3 changes: 3 additions & 0 deletions examples/example_vm/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
InheritParentConfig: true
Checks: >
-misc-const-correctness
2 changes: 1 addition & 1 deletion lib/loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ evmc_create_fn evmc_load(const char* filename, enum evmc_loader_error_code* erro
return create_fn;
}

const char* evmc_last_error_msg()
const char* evmc_last_error_msg(void)
{
const char* m = last_error_msg;
last_error_msg = NULL;
Expand Down
22 changes: 11 additions & 11 deletions test/compilation/compilation_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

#include <evmc/evmc.h>
#include <evmc/evmc.hpp>
#include <evmc/filter_iterator.hpp>
#include <evmc/helpers.h>
#include <evmc/hex.hpp>
#include <evmc/instructions.h>
#include <evmc/loader.h>
#include <evmc/mocked_host.hpp>
#include <evmc/utils.h>
#include <evmc/hex.hpp>
#include <evmc/filter_iterator.hpp>

// Include again to check if headers have proper include guards.
#include <evmc/evmc.h>
#include <evmc/evmc.hpp>
#include <evmc/helpers.h>
#include <evmc/instructions.h>
#include <evmc/loader.h>
#include <evmc/mocked_host.hpp>
#include <evmc/utils.h>
#include <evmc/hex.hpp>
#include <evmc/filter_iterator.hpp>
#include <evmc/evmc.h> //NOLINT(readability-duplicate-include)
#include <evmc/evmc.hpp> //NOLINT(readability-duplicate-include)
#include <evmc/filter_iterator.hpp> //NOLINT(readability-duplicate-include)
#include <evmc/helpers.h> //NOLINT(readability-duplicate-include)
#include <evmc/hex.hpp> //NOLINT(readability-duplicate-include)
#include <evmc/instructions.h> //NOLINT(readability-duplicate-include)
#include <evmc/loader.h> //NOLINT(readability-duplicate-include)
#include <evmc/mocked_host.hpp> //NOLINT(readability-duplicate-include)
#include <evmc/utils.h> //NOLINT(readability-duplicate-include)
18 changes: 9 additions & 9 deletions test/unittests/cpp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,14 @@ TEST(cpp, literals)
evmc::bytes32{});

auto a1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_address;
evmc::address e1{{{0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9}}};
const evmc::address e1{{{0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9}}};
EXPECT_EQ(a1, e1);

auto h1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_bytes32;
evmc::bytes32 f1{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0xa1,
0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xb0, 0xc1, 0xc2,
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd0, 0xd1, 0xd2}}};
const evmc::bytes32 f1{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0xa1,
0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xb0, 0xc1, 0xc2,
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd0, 0xd1, 0xd2}}};
EXPECT_EQ(h1, f1);
}

Expand Down Expand Up @@ -532,7 +532,7 @@ TEST(cpp, vm_set_option_in_constructor)

TEST(cpp, vm_null)
{
evmc::VM vm;
const evmc::VM vm;
EXPECT_FALSE(vm);
EXPECT_TRUE(!vm);
EXPECT_EQ(vm.get_raw_pointer(), nullptr);
Expand Down Expand Up @@ -622,7 +622,7 @@ TEST(cpp, vm_execute_with_null_host)
auto host = NullHost{};

auto vm = evmc::VM{evmc_create_example_vm()};
evmc_message msg{};
const evmc_message msg{};
auto res = vm.execute(host, EVMC_FRONTIER, msg, nullptr, 0);
EXPECT_EQ(res.status_code, EVMC_SUCCESS);
EXPECT_EQ(res.gas_left, 0);
Expand Down Expand Up @@ -943,7 +943,7 @@ TEST(cpp, status_code_to_string_invalid)
if (!has_ubsan())
{
std::ostringstream os;
int value = 99;
int value = 99; // NOLINT(misc-const-correctness) Not const because GCC complains.
const auto invalid = static_cast<evmc_status_code>(value);
EXPECT_STREQ(evmc::to_string(invalid), "<unknown>");
os << invalid;
Expand All @@ -956,7 +956,7 @@ TEST(cpp, revision_to_string_invalid)
if (!has_ubsan())
{
std::ostringstream os;
int value = 99;
int value = 99; // NOLINT(misc-const-correctness) Not const because GCC complains.
const auto invalid = static_cast<evmc_revision>(value);
EXPECT_STREQ(evmc::to_string(invalid), "<unknown>");
os << invalid;
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/loader_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static evmc_create_fn evmc_test_get_symbol_address(int handle, const char* symbo
return NULL;
}

static const char* evmc_test_get_last_error_msg()
static const char* evmc_test_get_last_error_msg(void)
{
// Return the last error message only once.
const char* m = evmc_test_last_error_msg;
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/loader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ TEST_F(loader, load_windows_path)

for (auto& path : paths)
{
bool should_open = is_windows || std::strchr(path, '\\') == nullptr;
const bool should_open = is_windows || std::strchr(path, '\\') == nullptr;
setup(should_open ? path : nullptr, "evmc_create_eee_bbb", create_eee_bbb);

evmc_loader_error_code ec = EVMC_LOADER_UNSPECIFIED_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion tools/evmc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main(int argc, const char** argv) noexcept

try
{
HexOrFileValidator HexOrFile;
const HexOrFileValidator HexOrFile;

std::string vm_config;
std::string code_arg;
Expand Down
57 changes: 29 additions & 28 deletions tools/vmtester/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ TEST_F(evmc_vm_test, capabilities)
TEST_F(evmc_vm_test, execute_call)
{
evmc::MockedHost mockedHost;
evmc_message msg{};
const evmc_message msg{};
std::array<uint8_t, 2> code = {{0xfe, 0x00}};

evmc_result result =
const evmc_result result =
vm->execute(vm, &evmc::MockedHost::get_interface(), mockedHost.to_context(),
EVMC_MAX_REVISION, &msg, code.data(), code.size());

Expand Down Expand Up @@ -87,20 +87,20 @@ TEST_F(evmc_vm_test, execute_call)
TEST_F(evmc_vm_test, execute_create)
{
evmc::MockedHost mockedHost;
evmc_message msg{EVMC_CREATE,
0,
0,
65536,
evmc_address{},
evmc_address{},
nullptr,
0,
evmc_uint256be{},
evmc_bytes32{},
evmc_address{}};
const evmc_message msg{EVMC_CREATE,
0,
0,
65536,
evmc_address{},
evmc_address{},
nullptr,
0,
evmc_uint256be{},
evmc_bytes32{},
evmc_address{}};
std::array<uint8_t, 2> code = {{0xfe, 0x00}};

evmc_result result =
const evmc_result result =
vm->execute(vm, &evmc::MockedHost::get_interface(), mockedHost.to_context(),
EVMC_MAX_REVISION, &msg, code.data(), code.size());

Expand Down Expand Up @@ -142,7 +142,7 @@ TEST_F(evmc_vm_test, set_option_empty_value)
{
if (vm->set_option != nullptr)
{
evmc_set_option_result r = vm->set_option(vm, "unknown_option_csk9twq", nullptr);
const auto r = vm->set_option(vm, "unknown_option_csk9twq", nullptr);
EXPECT_EQ(r, EVMC_SET_OPTION_INVALID_NAME);
}
}
Expand Down Expand Up @@ -178,19 +178,20 @@ TEST_F(evmc_vm_test, precompile_test)
addr.bytes[18] = static_cast<uint8_t>(i >> 8);
addr.bytes[19] = static_cast<uint8_t>(i & 0xff);

evmc_message msg{EVMC_CALL,
0,
0,
65536,
evmc_address{},
evmc_address{},
nullptr,
0,
evmc_uint256be{},
evmc_bytes32{},
addr};

evmc_result result = vm->execute(vm, nullptr, nullptr, EVMC_MAX_REVISION, &msg, nullptr, 0);
const evmc_message msg{EVMC_CALL,
0,
0,
65536,
evmc_address{},
evmc_address{},
nullptr,
0,
evmc_uint256be{},
evmc_bytes32{},
addr};

const evmc_result result =
vm->execute(vm, nullptr, nullptr, EVMC_MAX_REVISION, &msg, nullptr, 0);

// Validate some constraints

Expand Down