Fix unary minus warnings

No longer disable wd4146, fix warnings, and disable this warning when
including LLVM headers in LLVMReactor.cpp, as it trips for specific
headers like MathExtras.h, StringExtras.h.

Fixes ANGLE roll.

Bug: angleproject:4034
Change-Id: I102f4c18ac47c2db8abddf1b4ceace7987e6df57
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37488
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5b498b3..7e02987 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -323,7 +323,6 @@
         "/wd4018" # 'expression' : signed/unsigned mismatch
         "/wd4065" # switch statement contains 'default' but no 'case' labels
         "/wd4141" # 'modifier' : used more than once
-        "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
         "/wd4244" # 'conversion' conversion from 'type1' to 'type2', possible loss of data
         "/wd4267" # 'var' : conversion from 'size_t' to 'type', possible loss of data
         "/wd4291" # 'void X new(size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception
@@ -1559,6 +1558,7 @@
 
     if(WIN32)
         list(APPEND SUBZERO_COMPILE_OPTIONS
+            "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
             "/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
             "/wd4996" # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: new_name.
         )
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 29b18a9..c42bc1b 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -33,6 +33,11 @@
 #pragma clang diagnostic ignored "-Wextra-semi"
 #endif  // defined(__clang__)
 
+#ifdef _MSC_VER
+__pragma(warning(push))
+__pragma(warning(disable : 4146)) // unary minus operator applied to unsigned type, result still unsigned
+#endif
+
 #include "llvm/Analysis/LoopPass.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/JITSymbol.h"
@@ -67,6 +72,10 @@
 #pragma clang diagnostic pop
 #endif // defined(__clang__)
 
+#ifdef _MSC_VER
+__pragma(warning(pop))
+#endif
+
 #define ARGS(...) {__VA_ARGS__}
 #define CreateCall2 CreateCall
 #define CreateCall3 CreateCall
diff --git a/src/WSI/Win32SurfaceKHR.cpp b/src/WSI/Win32SurfaceKHR.cpp
index 05e6068..7ce07aa 100644
--- a/src/WSI/Win32SurfaceKHR.cpp
+++ b/src/WSI/Win32SurfaceKHR.cpp
@@ -131,7 +131,7 @@
 	bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFO);
 	bitmapInfo.bmiHeader.biBitCount = 32;
 	bitmapInfo.bmiHeader.biPlanes = 1;
-	bitmapInfo.bmiHeader.biHeight = -windowExtent.height;
+	bitmapInfo.bmiHeader.biHeight = -static_cast<LONG>(windowExtent.height); // Negative for top-down DIB, origin in upper-left corner
 	bitmapInfo.bmiHeader.biWidth = windowExtent.width;
 	bitmapInfo.bmiHeader.biCompression = BI_RGB;