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
@@ -11914,7 +11925,7 @@ struct VM {
1191411925 return false;
1191511926 }
1191611927
11917- CONTEXT ctx = { 0 };
11928+ CONTEXT ctx{ };
1191811929 ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
1191911930 nt_get_context_thread(current_thread, &ctx);
1192011931
@@ -11950,6 +11961,9 @@ struct VM {
1195011961 #endif
1195111962 }
1195211963 // ADD NEW TECHNIQUE FUNCTION HERE
11964+ #if (CLANG)
11965+ #pragma clang diagnostic pop
11966+ #endif
1195311967#endif
1195411968
1195511969
@@ -12338,6 +12352,9 @@ struct VM {
1233812352 , [[maybe_unused]] const std::source_location& loc = std::source_location::current()
1233912353 #endif
1234012354 ) {
12355+ #if (SOURCE_LOCATION_SUPPORTED)
12356+ VMAWARE_UNUSED(loc);
12357+ #endif
1234112358 if (util::is_unsupported(flag_bit)) {
1234212359 memo::cache_store(flag_bit, false, 0);
1234312360 return false;
@@ -12365,7 +12382,9 @@ struct VM {
1236512382 throw_error("Flag argument must be a technique flag and not a settings flag");
1236612383 }
1236712384
12368- #if (VMA_CPP >= 23)
12385+ #if (MSVC && !CLANG)
12386+ __assume(flag_bit < technique_end);
12387+ #elif (VMA_CPP >= 23)
1236912388 [[assume(flag_bit < technique_end)]];
1237012389 #endif
1237112390
@@ -12521,23 +12540,28 @@ struct VM {
1252112540 , const std::source_location& loc = std::source_location::current()
1252212541 #endif
1252312542 ) {
12524- // lambda to throw the error
12543+ #if (SOURCE_LOCATION_SUPPORTED)
12544+ VMAWARE_UNUSED(loc);
12545+ #endif
12546+
1252512547 auto throw_error = [&](const char* text) -> void {
1252612548 std::stringstream ss;
12527- #if (VMA_CPP >= 20 && !CLANG)
12549+ #if (VMA_CPP >= 20 && !CLANG)
1252812550 ss << ", error in " << loc.function_name() << " at " << loc.file_name() << ":" << loc.line() << ")";
12529- #endif
12551+ #endif
1253012552 ss << ". Consult the documentation's parameters for VM::add_custom()";
1253112553 throw std::invalid_argument(std::string(text) + ss.str());
1253212554 };
1253312555
1253412556 if (percent > 100) {
1253512557 throw_error("Percentage parameter must be between 0 and 100");
1253612558 }
12537-
12538- #if (VMA_CPP >= 23)
12539- [[assume(percent > 0 && percent <= 100)]];
12540- #endif
12559+
12560+ #if (MSVC && !CLANG)
12561+ __assume(percent > 0 && percent <= 100);
12562+ #elif (VMA_CPP >= 23)
12563+ [[assume(percent > 0 && percent <= 100)]];
12564+ #endif
1254112565
1254212566 size_t current_index = core::custom_table.size();
1254312567
@@ -12716,12 +12740,15 @@ struct VM {
1271612740 , const std::source_location& loc = std::source_location::current()
1271712741 #endif
1271812742 ) {
12719- // lambda to throw the error
12743+ #if (SOURCE_LOCATION_SUPPORTED)
12744+ VMAWARE_UNUSED(loc);
12745+ #endif
12746+
1272012747 auto throw_error = [&](const char* text) -> void {
1272112748 std::stringstream ss;
12722- #if (VMA_CPP >= 20 && !CLANG)
12749+ #if (VMA_CPP >= 20 && !CLANG)
1272312750 ss << ", error in " << loc.function_name() << " at " << loc.file_name() << ":" << loc.line() << ")";
12724- #endif
12751+ #endif
1272512752 ss << ". Consult the documentation's parameters for VM::modify_score()";
1272612753 throw std::invalid_argument(std::string(text) + ss.str());
1272712754 };
@@ -12730,9 +12757,11 @@ struct VM {
1273012757 throw_error("Percentage parameter must be between 0 and 100");
1273112758 }
1273212759
12733- #if (VMA_CPP >= 23)
12734- [[assume(percent <= 100)]];
12735- #endif
12760+ #if (MSVC && !CLANG)
12761+ __assume(percent <= 100);
12762+ #elif (VMA_CPP >= 23)
12763+ [[assume(percent <= 100)]];
12764+ #endif
1273612765
1273712766 // check if the flag provided is a setting flag, which isn't valid
1273812767 if (static_cast<u8>(flag) >= technique_end) {
0 commit comments