asar coverage - build #239


src/asar/
File: src/asar/warnings.h
Date: 2025-02-21 02:53:30
Lines:
2/2
100.0%
Functions:
1/1
100.0%
Branches:
0/0
-%

Line Branch Exec Source
1 #pragma once
2
3 #define ALL_WARNINGS(WRN) \
4 WRN(relative_path_used, "Relative %s path passed to asar_patch_ex() - please use absolute paths only to prevent undefined behavior!") \
5 WRN(rom_too_short, "ROM is too short to have a title. (Expected '%s')") \
6 WRN(rom_title_incorrect, "ROM title is incorrect. Expected '%s', got '%s'.") \
7 WRN(spc700_assuming_8_bit, "This opcode does not exist with 16-bit parameters, assuming 8-bit.") \
8 WRN(assuming_address_mode, "The addressing mode %s is not valid for this instruction, assuming %s.%s") \
9 WRN(set_middle_byte, "It would be wise to set the 008000 bit of this address.") \
10 WRN(freespace_leaked, "This freespace appears to be leaked.") \
11 WRN(warn_command, "warn command%s") \
12 WRN(implicitly_sized_immediate, "Implicitly sized immediate.", false) \
13 WRN(check_memory_file, "Accessing file '%s' which is not in memory while W%d is enabled.", false) \
14 WRN(datasize_last_label, "Datasize used on last detected label '%s'.") \
15 WRN(datasize_exceeds_size, "Datasize exceeds 0xFFFF for label '%s'.") \
16 WRN(mapper_already_set, "A mapper has already been selected.") \
17 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.") \
18 WRN(invalid_warning_id, "Warning '%s' (passed to %s) doesn't exist.") \
19 WRN(byte_order_mark_utf8, "UTF-8 byte order mark detected and skipped.") \
20 // this line intentionally left blank
21
22 enum asar_warning_id : int {
23 #define DO(id, ...) warning_id_ ## id,
24 ALL_WARNINGS(DO)
25 #undef DO
26 warning_id_end,
27 };
28
29 struct asar_warning_mapping {
30 const char* name;
31 const char* fmt_string;
32 bool default_enabled = true;
33 };
34
35 inline constexpr asar_warning_mapping asar_all_warnings[] = {
36 #define DO(id, ...) { "W" #id, __VA_ARGS__ },
37 ALL_WARNINGS(DO)
38 #undef DO
39 };
40
41 1093 constexpr const char* get_warning_fmt(asar_warning_id warnid) {
42 1093 return asar_all_warnings[warnid].fmt_string;
43 }
44
45 // see errors.h for some explanation of this whole mess
46 #ifdef __clang__
47 #pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
48 #endif
49 #if defined(__clang__) || defined(__GNUC__)
50 [[gnu::format(printf, 3, 4)]]
51 #endif
52 void asar_throw_warning_impl(int whichpass, asar_warning_id warnid, const char* fmt, ...);
53 #define asar_throw_warning(whichpass, warnid, ...) asar_throw_warning_impl(whichpass, warnid, get_warning_fmt(warnid), ## __VA_ARGS__)
54 const char* get_warning_name(asar_warning_id warnid);
55
56 void set_warning_enabled(asar_warning_id warnid, bool enabled);
57
58 // Supported string format: wXXXX, WXXXX or XXXX.
59 // Returns warning_id_end if the string is malformed
60 // or the ID wasn't found.
61 asar_warning_id parse_warning_id_from_string(const char* string);
62
63 void reset_warnings_to_default();
64
65 void push_warnings(bool warnings_command = true);
66 void pull_warnings(bool warnings_command = true);
67 void verify_warnings();
68