Common: Warning fixes for clang-cl

This commit is contained in:
Stenzek 2022-12-25 15:56:43 +10:00 committed by refractionpcsx2
parent 5c95a6f4fa
commit ca92d4ea3d
17 changed files with 68 additions and 21 deletions

View File

@ -91,6 +91,7 @@ target_sources(common PRIVATE
PrecompiledHeader.h
ProgressCallback.h
ReadbackSpinManager.h
RedtapeWilCom.h
RedtapeWindows.h
SafeArray.h
ScopedGuard.h

View File

@ -114,7 +114,7 @@ static void WriteMinidumpAndCallstack(PEXCEPTION_POINTERS exi)
{
char line[1024];
DWORD written;
std::snprintf(line, std::size(line), "Exception 0x%08X at 0x%p\n", exi->ExceptionRecord->ExceptionCode,
std::snprintf(line, std::size(line), "Exception 0x%08X at 0x%p\n", static_cast<unsigned>(exi->ExceptionRecord->ExceptionCode),
exi->ExceptionRecord->ExceptionAddress);
WriteFile(hFile, line, static_cast<DWORD>(std::strlen(line)), &written, nullptr);
}

View File

@ -17,13 +17,14 @@
#include "common/Pcsx2Defs.h"
#include "common/HashCombine.h"
#include "common/RedtapeWindows.h"
#include "common/RedtapeWilCom.h"
#include "common/D3D11/ShaderCompiler.h"
#include <cstdio>
#include <d3d11.h>
#include <string_view>
#include <unordered_map>
#include <vector>
#include <wil/com.h>
namespace D3D11
{

View File

@ -14,11 +14,13 @@
*/
#pragma once
#include "common/RedtapeWindows.h"
#include "common/RedtapeWilCom.h"
#include <d3d11.h>
#include <string_view>
#include <type_traits>
#include <wil/com.h>
namespace D3D11::ShaderCompiler
{

View File

@ -17,10 +17,10 @@
#include "common/Pcsx2Defs.h"
#include "common/RedtapeWindows.h"
#include "common/RedtapeWilCom.h"
#include <array>
#include <d3d12.h>
#include <wil/com.h>
namespace D3D12
{

View File

@ -18,13 +18,13 @@
#include "common/Pcsx2Defs.h"
#include "common/HashCombine.h"
#include "common/RedtapeWindows.h"
#include "common/RedtapeWilCom.h"
#include <bitset>
#include <cstring>
#include <d3d12.h>
#include <unordered_map>
#include <vector>
#include <wil/com.h>
namespace D3D12
{

View File

@ -18,13 +18,13 @@
#include "common/Pcsx2Defs.h"
#include "common/HashCombine.h"
#include "common/RedtapeWindows.h"
#include "common/RedtapeWilCom.h"
#include <cstdio>
#include <d3d12.h>
#include <string_view>
#include <unordered_map>
#include <vector>
#include <wil/com.h>
namespace D3D12
{

View File

@ -17,11 +17,11 @@
#include "common/Pcsx2Defs.h"
#include "common/RedtapeWindows.h"
#include "common/RedtapeWilCom.h"
#include <d3d12.h>
#include <deque>
#include <utility>
#include <wil/com.h>
namespace D3D12MA
{

View File

@ -20,17 +20,17 @@
static void* GetProcAddressCallback(const char* name)
{
void* addr = wglGetProcAddress(name);
void* addr = reinterpret_cast<void*>(wglGetProcAddress(name));
if (addr)
return addr;
// try opengl32.dll
return ::GetProcAddress(GetModuleHandleA("opengl32.dll"), name);
return reinterpret_cast<void*>(::GetProcAddress(GetModuleHandleA("opengl32.dll"), name));
}
static bool ReloadWGL(HDC dc)
{
if (!gladLoadWGLLoader([](const char* name) -> void* { return wglGetProcAddress(name); }, dc))
if (!gladLoadWGLLoader([](const char* name) -> void* { return reinterpret_cast<void*>(wglGetProcAddress(name)); }, dc))
{
Console.Error("Loading GLAD WGL functions failed");
return false;
@ -208,7 +208,7 @@ namespace GL
if (!hDC)
{
Console.Error("GetDC() failed: 0x%08X", GetLastError());
return false;
return {};
}
if (!m_pixel_format.has_value())
@ -218,7 +218,7 @@ namespace GL
{
Console.Error("ChoosePixelFormat() failed: 0x%08X", GetLastError());
::ReleaseDC(hwnd, hDC);
return false;
return {};
}
m_pixel_format = pf;
@ -397,7 +397,7 @@ namespace GL
}
// re-init glad-wgl
if (!gladLoadWGLLoader([](const char* name) -> void* { return wglGetProcAddress(name); }, m_dc))
if (!gladLoadWGLLoader([](const char* name) -> void* { return reinterpret_cast<void*>(wglGetProcAddress(name)); }, m_dc))
{
Console.Error("Loading GLAD WGL functions failed");
return false;

View File

@ -159,7 +159,7 @@ static constexpr size_t __pagemask = PCSX2_PAGESIZE - 1;
// Makes sure that if anyone includes xbyak, it doesn't do anything bad
#define XBYAK_ENABLE_OMITTED_OPERAND
#ifdef __x86_64__
#if defined(__x86_64__) && !defined(_M_AMD64)
#define _M_AMD64
#endif

34
common/RedtapeWilCom.h Normal file
View File

@ -0,0 +1,34 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2022 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifdef _WIN32
#include "common/RedtapeWindows.h"
// warning : variable 's_hrErrorLast' set but not used [-Wunused-but-set-variable]
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#endif
#include <wil/com.h>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif

View File

@ -566,6 +566,8 @@ private:
case 8: //SymVirtual:
szSymType = "Virtual";
break;
default:
break;
}
}
LPCSTR pdbName = Module.LoadedImageName;
@ -1199,9 +1201,12 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
OSVERSIONINFOEXA ver;
ZeroMemory(&ver, sizeof(OSVERSIONINFOEXA));
ver.dwOSVersionInfoSize = sizeof(ver);
#if _MSC_VER >= 1900
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4996)
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
if (GetVersionExA((OSVERSIONINFOA*)&ver) != FALSE)
{
@ -1211,8 +1216,10 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
OnOutput(buffer);
}
#if _MSC_VER >= 1900
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
}

View File

@ -187,7 +187,7 @@ static bool VMMMarkPagesAsInUse(std::atomic<bool>* begin, std::atomic<bool>* end
for (auto current = begin; current < end; current++)
{
bool expected = false;
if (!current->compare_exchange_strong(expected, true), std::memory_order_relaxed)
if (!current->compare_exchange_strong(expected, true, std::memory_order_relaxed))
{
// This was already allocated! Undo the things we've set until this point
while (--current >= begin)

View File

@ -99,6 +99,7 @@
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-completeness"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#define VMA_STATIC_VULKAN_FUNCTIONS 1

View File

@ -44,6 +44,8 @@ namespace Vulkan
DestroySurface();
}
#if 0
// Unused for now, can be used for nogui
static VkSurfaceKHR CreateDisplaySurface(VkInstance instance, VkPhysicalDevice physical_device, WindowInfo* wi)
{
Console.WriteLn("Trying to create a VK_KHR_display surface of %ux%u", wi->surface_width, wi->surface_height);
@ -253,6 +255,7 @@ namespace Vulkan
return result;
}
#endif
VkSurfaceKHR SwapChain::CreateVulkanSurface(VkInstance instance, VkPhysicalDevice physical_device, WindowInfo* wi)
{

View File

@ -286,8 +286,6 @@ bool SharedMemoryMappingArea::Unmap(void* map_base, size_t map_size)
pxAssert(Common::IsAlignedPow2(map_offset, __pagesize));
pxAssert(Common::IsAlignedPow2(map_size, __pagesize));
const size_t page = map_offset / __pagesize;
// unmap the specified range
if (!UnmapViewOfFile2(GetCurrentProcess(), map_base, MEM_PRESERVE_PLACEHOLDER))
{

View File

@ -46,7 +46,7 @@ using namespace x86Emitter;
alignas(16) x86capabilities x86caps;
#ifdef _MSC_VER
#if defined(_MSC_VER)
// We disable optimizations for this function, because we need x86capabilities for AVX
// detection, but if we keep opts on, it'll use AVX instructions for inlining memzero.
#pragma optimize("", off)
@ -70,7 +70,7 @@ x86capabilities::x86capabilities()
memzero(VendorName);
memzero(FamilyName);
}
#ifdef _MSC_VER
#if defined(_MSC_VER)
#pragma optimize("", on)
#endif