asar coverage - build #292


src/asar/
File: src/asar/warnings.h
Date: 2025-03-10 15:35:02
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 static constexpr int warn_id_##id = __LINE__ - _warn_startline; \
18 SAVE_WARN_NAME(warn_id_##id, "W" #id, is_enabled); \
19 template<typename... Ts> inline void warn_ ## id(int whichpass, Ts... args) { \
20 warn_impl(warn_id_##id, fmt_string, whichpass, args...); \
21 }
22
23 static constexpr int _warn_startline = __LINE__;
24 1 WRN(relative_path_used, "Relative %s path passed to asar_patch_ex() - please use absolute paths only to prevent undefined behavior!", true)
25 WRN(rom_too_short, "ROM is too short to have a title. (Expected '%s')", true)
26 WRN(rom_title_incorrect, "ROM title is incorrect. Expected '%s', got '%s'.", true)
27 WRN(spc700_assuming_8_bit, "This opcode does not exist with 16-bit parameters, assuming 8-bit.", true)
28 WRN(assuming_address_mode, "The addressing mode %s is not valid for this instruction, assuming %s.%s", true)
29 WRN(set_middle_byte, "It would be wise to set the 008000 bit of this address.", true)
30 WRN(freespace_leaked, "This freespace appears to be leaked.", true)
31 39 WRN(warn_command, "warn command%s", true)
32 99 WRN(implicitly_sized_immediate, "Implicitly sized immediate.", false)
33 569 WRN(check_memory_file, "Accessing file '%s' which is not in memory while Wcheck_memory_file is enabled.", false)
34 4 WRN(datasize_last_label, "Datasize used on last detected label '%s'.", true)
35 4 WRN(datasize_exceeds_size, "Datasize exceeds 0xFFFF for label '%s'.", true)
36 78 WRN(mapper_already_set, "A mapper has already been selected.", true)
37 WRN(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)
38 18 WRN(invalid_warning_id, "Warning '%s' (passed to %s) doesn't exist.", true)
39 2 WRN(byte_order_mark_utf8, "UTF-8 byte order mark detected and skipped.", true)
40
41 #undef WRN
42 #define throw_warning(whichpass, id, ...) id(whichpass, ## __VA_ARGS__)
43
44 using asar_warning_id = int;
45 extern asar_warning_id warning_id_end;
46 const char* get_warning_name(asar_warning_id warnid);
47
48 void set_warning_enabled(asar_warning_id warnid, bool enabled);
49
50 // Supported string format: wXXXX, WXXXX or XXXX.
51 // Returns warning_id_end if the string is malformed
52 // or the ID wasn't found.
53 asar_warning_id parse_warning_id_from_string(const char* string);
54
55 void reset_warnings_to_default();
56
57 void push_warnings(bool warnings_command = true);
58 void pull_warnings(bool warnings_command = true);
59 void verify_warnings();
60