Skip to content

Commit 944539c

Browse files
committed
llvm 21 linting fixes
1 parent abc5aa0 commit 944539c

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

src/unrealsdk/commands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace impl {
8181
#ifndef UNREALSDK_IMPORTING
8282

8383
bool is_command_valid(std::wstring_view line, bool direct_user_input) {
84-
if (direct_user_input && commands.find(NEXT_LINE) != commands.end()) {
84+
if (direct_user_input && commands.contains(NEXT_LINE)) {
8585
return true;
8686
}
8787
auto non_space = std::ranges::find_if_not(line, &std::iswspace);

src/unrealsdk/hook_manager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ std::mutex log_all_calls_stream_mutex{};
137137
void log_all_calls(bool should_log) {
138138
// Only keep this file stream open while we need it
139139
if (should_log) {
140-
const std::lock_guard<std::mutex> lock(log_all_calls_stream_mutex);
140+
const std::scoped_lock lock(log_all_calls_stream_mutex);
141141
log_all_calls_stream.open(
142142
utils::get_this_dll().parent_path()
143143
/ config::get_str("unrealsdk.log_all_calls_file").value_or("unrealsdk.calls.tsv"),
@@ -147,7 +147,7 @@ void log_all_calls(bool should_log) {
147147
should_log_all_calls = should_log;
148148

149149
if (!should_log) {
150-
const std::lock_guard<std::mutex> lock(log_all_calls_stream_mutex);
150+
const std::scoped_lock lock(log_all_calls_stream_mutex);
151151
log_all_calls_stream.close();
152152
}
153153
}
@@ -432,7 +432,7 @@ std::shared_ptr<Node> preprocess_hook(std::wstring_view source,
432432
func_name = func->get_path_name();
433433
auto obj_name = obj->get_path_name();
434434

435-
const std::lock_guard<std::mutex> lock(log_all_calls_stream_mutex);
435+
const std::scoped_lock lock(log_all_calls_stream_mutex);
436436
log_all_calls_stream << source << L'\t' << func_name << L'\t' << obj_name << L'\n';
437437
}
438438
}

src/unrealsdk/logging.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ std::vector<log_callback> all_log_callbacks{};
6767
}
6868

6969
{
70-
const std::lock_guard<std::mutex> callback_lock(callback_mutex);
70+
const std::scoped_lock callback_lock(callback_mutex);
7171
while (!pending_messages.empty()) {
7272
auto msg = std::move(pending_messages.front());
7373
pending_messages.pop();
@@ -289,7 +289,7 @@ void enqueue_log_msg(uint64_t unix_time_ms,
289289
size_t location_size,
290290
int line) {
291291
{
292-
const std::lock_guard<std::mutex> lock(pending_messages_mutex);
292+
const std::scoped_lock lock(pending_messages_mutex);
293293
pending_messages.emplace(unix_time_ms, level, msg, msg_size, location, location_size, line);
294294
}
295295
pending_messages_available.notify_all();
@@ -305,13 +305,13 @@ bool set_console_level(Level level) {
305305
}
306306

307307
void add_callback(log_callback callback) {
308-
const std::lock_guard<std::mutex> lock(callback_mutex);
308+
const std::scoped_lock lock(callback_mutex);
309309

310310
all_log_callbacks.push_back(callback);
311311
}
312312

313313
void remove_callback(log_callback callback) {
314-
const std::lock_guard<std::mutex> lock(callback_mutex);
314+
const std::scoped_lock lock(callback_mutex);
315315

316316
auto [begin, end] = std::ranges::remove(all_log_callbacks, callback);
317317
all_log_callbacks.erase(begin, end);

src/unrealsdk/unreal/structs/fframe.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace unrealsdk::unreal {
99

1010
uint8_t* FFrame::extract_current_args(WrappedStruct& args) {
1111
auto args_addr = reinterpret_cast<uintptr_t>(args.base.get());
12+
// NOLINTNEXTLINE(misc-const-correctness) - see llvm/llvm-project#157320
1213
uint8_t* original_code = this->Code;
1314

1415
for (auto prop = reinterpret_cast<UProperty*>(args.type->Children());

src/unrealsdk/unreal/structs/fscriptdelegate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void FScriptDelegate::validate_signature(const std::optional<BoundFunction>& fun
6464
// Since delegates store the function name, make sure we can find this function again from just
6565
// it's name
6666
{
67-
UFunction* func_from_find = nullptr;
67+
const UFunction* func_from_find = nullptr;
6868
try {
6969
func_from_find = func->object->Class()->find_func_and_validate(func->func->Name());
7070
} catch (const std::invalid_argument&) {

src/unrealsdk/unrealsdk_main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ std::unordered_set<void*> unreal_allocations{};
4545
#endif
4646

4747
bool init(const std::function<std::unique_ptr<game::AbstractHook>(void)>& game_getter) {
48-
const std::lock_guard<std::mutex> lock(init_mutex);
48+
const std::scoped_lock lock(init_mutex);
4949

5050
if (hook_instance != nullptr) {
5151
return false;
@@ -75,12 +75,12 @@ bool init(const std::function<std::unique_ptr<game::AbstractHook>(void)>& game_g
7575
}
7676

7777
UNREALSDK_CAPI([[nodiscard]] bool, is_initialized) {
78-
const std::lock_guard<std::mutex> lock(init_mutex);
78+
const std::scoped_lock lock(init_mutex);
7979
return hook_instance != nullptr;
8080
}
8181

8282
UNREALSDK_CAPI([[nodiscard]] bool, is_console_ready) {
83-
return hook_instance && hook_instance->is_console_ready();
83+
return is_initialized() && hook_instance->is_console_ready();
8484
}
8585

8686
UNREALSDK_CAPI([[nodiscard]] const GObjects*, gobjects) {

0 commit comments

Comments
 (0)