335335 #warning "Unknown OS detected, tests will be severely limited"
336336#endif
337337
338+ #if (CLANG)
339+ // This happens because Windows API structures or aliases are typedef'd inside a local scope (like inside a function) but never actually used
340+ #pragma clang diagnostic push
341+ #pragma clang diagnostic ignored "-Wunused-local-typedef"
342+ #endif
343+
338344#if (VMA_CPP >= 23)
339345 #include <limits>
340346#endif
@@ -4278,13 +4284,13 @@ struct VM {
42784284 UNICODE_STRING FullDllName;
42794285 BYTE Reserved4[8];
42804286 PVOID Reserved5[3];
4281- #pragma warning(push)
4282- #pragma warning(disable: 4201)
4287+ #if (MSVC)
4288+ #pragma warning(suppress: 4201)
4289+ #endif
42834290 union {
42844291 ULONG CheckSum;
42854292 PVOID Reserved6;
42864293 } DUMMYUNIONNAME;
4287- #pragma warning(pop)
42884294 ULONG TimeDateStamp;
42894295 } LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;
42904296
@@ -5382,11 +5388,18 @@ struct VM {
53825388 if (util::hyper_x() != HYPERV_UNKNOWN) threshold = 25.0;
53835389
53845390 // prevent false sharing when triggering hypervisor exits with the intentional data race condition
5391+ #if (MSVC)
5392+ #pragma warning(push)
5393+ #pragma warning(disable: 4324)
5394+ #endif
53855395 struct alignas(64) cache_state {
53865396 alignas(64) volatile u64 counter { 0 };
53875397 alignas(64) std::atomic<bool> start_test{ false };
53885398 alignas(64) std::atomic<bool> test_done{ false };
53895399 };
5400+ #if (MSVC)
5401+ #pragma warning(pop)
5402+ #endif
53905403
53915404 // Shared state and results
53925405 cache_state state;
@@ -8185,7 +8198,7 @@ struct VM {
81858198 PVOID, ULONG);
81868199 const auto nt_power_information = reinterpret_cast<NtPI_t>(funcs[0]);
81878200
8188- SYSTEM_POWER_CAPABILITIES caps = { 0 };
8201+ SYSTEM_POWER_CAPABILITIES caps{ };
81898202 const NTSTATUS status = nt_power_information(
81908203 SystemPowerCapabilities,
81918204 nullptr, 0,
@@ -8696,8 +8709,8 @@ struct VM {
86968709 * @implements VM::DEVICE_STRING
86978710 */
86988711 [[nodiscard]] static bool device_string() {
8699- DCB dcb = { 0 };
8700- COMMTIMEOUTS timeouts = { 0 };
8712+ DCB dcb{ };
8713+ COMMTIMEOUTS timeouts{ };
87018714
87028715 if (BuildCommDCBAndTimeoutsA("jhl46745fghb", &dcb, &timeouts)) {
87038716 return true;
@@ -9330,9 +9343,7 @@ struct VM {
93309343 * @implements VM::HYPERVISOR_QUERY
93319344 */
93329345 [[nodiscard]] static bool hypervisor_query() {
9333- #if (x86_32)
9334- return false;
9335- #else
9346+ #if (x86_64)
93369347 if (util::hyper_x() == HYPERV_ARTIFACT_VM) {
93379348 return false;
93389349 }
@@ -9369,7 +9380,7 @@ struct VM {
93699380
93709381 const FN_NtQuerySystemInformation nt_query_system_information = reinterpret_cast<FN_NtQuerySystemInformation>(funcs[0]);
93719382 if (nt_query_system_information) {
9372- SYSTEM_HYPERVISOR_DETAIL_INFORMATION hypervisor_information = { {} };
9383+ SYSTEM_HYPERVISOR_DETAIL_INFORMATION hypervisor_information{ };
93739384
93749385 // Request class 0x9F (SystemHypervisorDetailInformation)
93759386 // This asks the OS kernel to fill the structure with information about the
@@ -11909,7 +11920,7 @@ struct VM {
1190911920 return false;
1191011921 }
1191111922
11912- CONTEXT ctx = { 0 };
11923+ CONTEXT ctx{ };
1191311924 ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
1191411925 nt_get_context_thread(current_thread, &ctx);
1191511926
@@ -11944,6 +11955,9 @@ struct VM {
1194411955 return !ermsb_trap_detected;
1194511956 }
1194611957 // ADD NEW TECHNIQUE FUNCTION HERE
11958+ #if (CLANG)
11959+ #pragma clang diagnostic pop
11960+ #endif
1194711961#endif
1194811962
1194911963
@@ -12332,6 +12346,9 @@ struct VM {
1233212346 , [[maybe_unused]] const std::source_location& loc = std::source_location::current()
1233312347 #endif
1233412348 ) {
12349+ #if (SOURCE_LOCATION_SUPPORTED)
12350+ VMAWARE_UNUSED(loc);
12351+ #endif
1233512352 if (util::is_unsupported(flag_bit)) {
1233612353 memo::cache_store(flag_bit, false, 0);
1233712354 return false;
@@ -12359,7 +12376,9 @@ struct VM {
1235912376 throw_error("Flag argument must be a technique flag and not a settings flag");
1236012377 }
1236112378
12362- #if (VMA_CPP >= 23)
12379+ #if (MSVC && !CLANG)
12380+ __assume(flag_bit < technique_end);
12381+ #elif (VMA_CPP >= 23)
1236312382 [[assume(flag_bit < technique_end)]];
1236412383 #endif
1236512384
@@ -12515,23 +12534,28 @@ struct VM {
1251512534 , const std::source_location& loc = std::source_location::current()
1251612535 #endif
1251712536 ) {
12518- // lambda to throw the error
12537+ #if (SOURCE_LOCATION_SUPPORTED)
12538+ VMAWARE_UNUSED(loc);
12539+ #endif
12540+
1251912541 auto throw_error = [&](const char* text) -> void {
1252012542 std::stringstream ss;
12521- #if (VMA_CPP >= 20 && !CLANG)
12543+ #if (VMA_CPP >= 20 && !CLANG)
1252212544 ss << ", error in " << loc.function_name() << " at " << loc.file_name() << ":" << loc.line() << ")";
12523- #endif
12545+ #endif
1252412546 ss << ". Consult the documentation's parameters for VM::add_custom()";
1252512547 throw std::invalid_argument(std::string(text) + ss.str());
1252612548 };
1252712549
1252812550 if (percent > 100) {
1252912551 throw_error("Percentage parameter must be between 0 and 100");
1253012552 }
12531-
12532- #if (VMA_CPP >= 23)
12533- [[assume(percent > 0 && percent <= 100)]];
12534- #endif
12553+
12554+ #if (MSVC && !CLANG)
12555+ __assume(percent > 0 && percent <= 100);
12556+ #elif (VMA_CPP >= 23)
12557+ [[assume(percent > 0 && percent <= 100)]];
12558+ #endif
1253512559
1253612560 size_t current_index = core::custom_table.size();
1253712561
@@ -12710,12 +12734,15 @@ struct VM {
1271012734 , const std::source_location& loc = std::source_location::current()
1271112735 #endif
1271212736 ) {
12713- // lambda to throw the error
12737+ #if (SOURCE_LOCATION_SUPPORTED)
12738+ VMAWARE_UNUSED(loc);
12739+ #endif
12740+
1271412741 auto throw_error = [&](const char* text) -> void {
1271512742 std::stringstream ss;
12716- #if (VMA_CPP >= 20 && !CLANG)
12743+ #if (VMA_CPP >= 20 && !CLANG)
1271712744 ss << ", error in " << loc.function_name() << " at " << loc.file_name() << ":" << loc.line() << ")";
12718- #endif
12745+ #endif
1271912746 ss << ". Consult the documentation's parameters for VM::modify_score()";
1272012747 throw std::invalid_argument(std::string(text) + ss.str());
1272112748 };
@@ -12724,9 +12751,11 @@ struct VM {
1272412751 throw_error("Percentage parameter must be between 0 and 100");
1272512752 }
1272612753
12727- #if (VMA_CPP >= 23)
12728- [[assume(percent <= 100)]];
12729- #endif
12754+ #if (MSVC && !CLANG)
12755+ __assume(percent <= 100);
12756+ #elif (VMA_CPP >= 23)
12757+ [[assume(percent <= 100)]];
12758+ #endif
1273012759
1273112760 // check if the flag provided is a setting flag, which isn't valid
1273212761 if (static_cast<u8>(flag) >= technique_end) {
0 commit comments