Skip to content

Commit

Permalink
Fix build/analysis with Clang 18 (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast authored Dec 21, 2023
2 parents b2337d4 + d74b83a commit 9b5cc58
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ Checks: >
hicpp-multiway-paths-covered,
hicpp-no-assembler,
misc-*,
-misc-use-anonymous-namespace,
-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
-misc-use-anonymous-namespace,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
performance-*,
-performance-enum-size,
portability-*,
readability-*,
-readability-braces-around-statements,
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ if(CABLE_COMPILER_GNULIKE)
add_compile_options(
-Wmissing-declarations
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>
$<$<COMPILE_LANGUAGE:CXX>:-Wno-missing-field-initializers>

$<$<CXX_COMPILER_ID:GNU>:-Wno-attributes>
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wno-missing-field-initializers>
$<$<CXX_COMPILER_ID:GNU>:-Wduplicated-cond>
$<$<CXX_COMPILER_ID:GNU>:-Wlogical-op>

Expand Down
2 changes: 1 addition & 1 deletion lib/evmone/advanced_analysis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ using instruction_exec_fn = const Instruction* (*)(const Instruction*, AdvancedE
///
/// These intrinsic instructions may be injected to the code in the analysis phase.
/// They contain additional and required logic to be executed by the interpreter.
enum intrinsic_opcodes
enum intrinsic_opcodes : uint8_t
{
/// The BEGINBLOCK instruction.
///
Expand Down
2 changes: 1 addition & 1 deletion test/t8n/t8n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int main(int argc, const char* argv[])
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
return 1;
}

Expand Down
2 changes: 2 additions & 0 deletions test/unittests/eof_validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ TEST(eof_validation, get_error_message)
EXPECT_EQ(evmone::get_error_message(EOFValidationError::invalid_prefix), "invalid_prefix");
EXPECT_EQ(evmone::get_error_message(EOFValidationError::stack_overflow), "stack_overflow");
EXPECT_EQ(evmone::get_error_message(EOFValidationError::impossible), "impossible");

// NOLINTNEXTLINE(*.EnumCastOutOfRange)
EXPECT_EQ(evmone::get_error_message(static_cast<EOFValidationError>(-1)), "<unknown>");
}

Expand Down
5 changes: 1 addition & 4 deletions test/unittests/evm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,7 @@ TEST_P(evm, undefined_instruction_analysis_overflow)
{
rev = EVMC_PETERSBURG;

auto undefined_opcode = static_cast<Opcode>(0x0c);
auto code = bytecode{undefined_opcode};

execute(code);
execute(bytecode{"0c"}); // undefined opcode
EXPECT_EQ(result.status_code, EVMC_UNDEFINED_INSTRUCTION);
}

Expand Down
22 changes: 11 additions & 11 deletions test/unittests/execution_state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
#include <gtest/gtest.h>
#include <type_traits>

static_assert(std::is_default_constructible<evmone::ExecutionState>::value);
static_assert(!std::is_move_constructible<evmone::ExecutionState>::value);
static_assert(!std::is_copy_constructible<evmone::ExecutionState>::value);
static_assert(!std::is_move_assignable<evmone::ExecutionState>::value);
static_assert(!std::is_copy_assignable<evmone::ExecutionState>::value);

static_assert(std::is_default_constructible<evmone::advanced::AdvancedExecutionState>::value);
static_assert(!std::is_move_constructible<evmone::advanced::AdvancedExecutionState>::value);
static_assert(!std::is_copy_constructible<evmone::advanced::AdvancedExecutionState>::value);
static_assert(!std::is_move_assignable<evmone::advanced::AdvancedExecutionState>::value);
static_assert(!std::is_copy_assignable<evmone::advanced::AdvancedExecutionState>::value);
static_assert(std::is_default_constructible_v<evmone::ExecutionState>);
static_assert(!std::is_move_constructible_v<evmone::ExecutionState>);
static_assert(!std::is_copy_constructible_v<evmone::ExecutionState>);
static_assert(!std::is_move_assignable_v<evmone::ExecutionState>);
static_assert(!std::is_copy_assignable_v<evmone::ExecutionState>);

static_assert(std::is_default_constructible_v<evmone::advanced::AdvancedExecutionState>);
static_assert(!std::is_move_constructible_v<evmone::advanced::AdvancedExecutionState>);
static_assert(!std::is_copy_constructible_v<evmone::advanced::AdvancedExecutionState>);
static_assert(!std::is_move_assignable_v<evmone::advanced::AdvancedExecutionState>);
static_assert(!std::is_copy_assignable_v<evmone::advanced::AdvancedExecutionState>);

TEST(execution_state, construct)
{
Expand Down
6 changes: 3 additions & 3 deletions test/unittests/instructions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace
{
constexpr int unspecified = -1000000;

constexpr int get_revision_defined_in(size_t op) noexcept
constexpr int get_revision_defined_in(uint8_t op) noexcept
{
for (size_t r = EVMC_FRONTIER; r <= EVMC_MAX_REVISION; ++r)
{
Expand All @@ -32,7 +32,7 @@ constexpr int get_revision_defined_in(size_t op) noexcept
return unspecified;
}

constexpr bool is_terminating(Opcode op) noexcept
constexpr bool is_terminating(uint8_t op) noexcept
{
switch (op)
{
Expand All @@ -49,7 +49,7 @@ constexpr bool is_terminating(Opcode op) noexcept
}
}

template <Opcode Op>
template <uint8_t Op>
constexpr void validate_traits_of() noexcept
{
constexpr auto tr = instr::traits[Op];
Expand Down

0 comments on commit 9b5cc58

Please sign in to comment.