Skip to content

Commit d81cf9b

Browse files
committed
llarm-emu reinterpret_cast fix for clang-tidy
1 parent 2bda9ed commit d81cf9b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

cmake/clang_tidy.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ else()
77
endif()
88

99
function(configure_clang_tidy TARGET)
10-
if(CLANG_TIDY_EXE)
10+
if(CLANG_TIDY_EXE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
1111
set_target_properties(${TARGET} PROPERTIES
1212
CXX_CLANG_TIDY "${CLANG_TIDY_EXE};--use-color;--extra-arg=-Wno-unknown-warning-option"
1313
)

llarm-emu/llarm/llarm-emu.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ namespace llarm::emu {
6565
const std::size_t file_size = static_cast<std::size_t>(file.tellg());
6666
file.seekg(0);
6767

68-
std::vector<u8> data;
69-
data.reserve(file_size);
70-
data.assign(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
68+
std::vector<u8> data(file_size);
69+
70+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
71+
file.read(reinterpret_cast<char*>(data.data()), static_cast<std::streamsize>(file_size));
7172

7273
return data;
7374
}

0 commit comments

Comments
 (0)