asar coverage - build #325


src/asar/
File: src/asar/warnings.h
Date: 2025-11-04 16:32:25
Lines:
9/15
60.0%
Functions:
9/16
56.2%
Branches:
0/0
-%

Line Branch Exec Source
1 #pragma once
2
3 #ifdef __clang__
4 #pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
5 #endif
6
7 #if defined(__clang__) || defined(__GNUC__)
8 [[gnu::format(printf, 2, 4)]]
9 #endif
10 void warn_impl(int warn_id, const char* fmt_string, int whichpass, ...);
11
12 #ifndef SAVE_WARN_NAME
13 #define SAVE_WARN_NAME(...) // only used in warnings.cpp
14 #endif
15
16 #define WRN(id, fmt_string, is_enabled) \
17 SAVE_WARN_NAME(__LINE__ - _warn_startline, #id, is_enabled); \
18 template<typename... Ts> inline void id(int whichpass, Ts... args) { \
19 warn_impl(__LINE__ - _warn_startline, fmt_string, whichpass, args...); \
20 }
21
22 static constexpr int _warn_startline = __LINE__;
23 1 WRN(warn_relative_path_used, "Relative %s path passed to asar_patch_ex() - please use absolute paths only to prevent undefined behavior!", true)
24 WRN(warn_rom_too_short, "ROM is too short to have a title. (Expected '%s')", true)
25 WRN(warn_rom_title_incorrect, "ROM title is incorrect. Expected '%s', got '%s'.", true)
26 WRN(warn_spc700_assuming_8_bit, "This opcode does not exist with 16-bit parameters, assuming 8-bit.", true)
27 WRN(warn_assuming_address_mode, "The addressing mode %s is not valid for this instruction, assuming %s.%s", true)
28 WRN(warn_set_middle_byte, "It would be wise to set the 008000 bit of this address.", true)
29 WRN(warn_freespace_leaked, "This freespace appears to be leaked.", true)
30 33 WRN(warn_warn_command, "warn command%s", true)
31 99 WRN(warn_implicitly_sized_immediate, "Implicitly sized immediate.", false)
32 575 WRN(warn_check_memory_file, "Accessing file '%s' which is not in memory while Wcheck_memory_file is enabled.", false)
33 4 WRN(warn_datasize_last_label, "Datasize used on last detected label '%s'.", true)
34 4 WRN(warn_datasize_exceeds_size, "Datasize exceeds 0xFFFF for label '%s'.", true)
35 78 WRN(warn_mapper_already_set, "A mapper has already been selected.", true)
36 WRN(warn_feature_deprecated, "DEPRECATION NOTIFICATION: Feature \"%s\" is deprecated and will be REMOVED in the future. Please update your code to conform to newer styles. Suggested work around: %s.", true)
37 18 WRN(warn_invalid_warning_id, "Warning '%s' (passed to %s) doesn't exist.", true)
38 2 WRN(warn_byte_order_mark_utf8, "UTF-8 byte order mark detected and skipped.", true)
39
40 #undef WRN
41 #define throw_warning(whichpass, id, ...) id(whichpass, ## __VA_ARGS__)
42
43 using asar_warning_id = int;
44 extern asar_warning_id warning_id_end;
45 const char* get_warning_name(asar_warning_id warnid);
46
47 void set_warning_enabled(asar_warning_id warnid, bool enabled);
48
49 // Supported string format: wXXXX, WXXXX or XXXX.
50 // Returns warning_id_end if the string is malformed
51 // or the ID wasn't found.
52 asar_warning_id parse_warning_id_from_string(const char* string);
53
54 void reset_warnings_to_default();
55
56 void push_warnings(bool warnings_command = true);
57 void pull_warnings(bool warnings_command = true);
58 void verify_warnings();
59