blob: 52956f95baafb5ab775c2edabcd108f163834e4b [file] [log] [blame]
James Kuszmaulb13e13f2023-11-22 20:44:04 -08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Benjamin Hall <bhallctre@gmail.com>
3Date: Mon, 23 Oct 2023 21:36:40 -0400
4Subject: [PATCH 32/32] Fix compilation of MathExtras.h on Windows with /sdl
5
6See https://github.com/llvm/llvm-project/pull/68978
7---
8 llvm/include/llvm/Support/MathExtras.h | 5 ++++-
9 1 file changed, 4 insertions(+), 1 deletion(-)
10
11diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
12index 5f034b694989d8ef24e0b249abd12a5c20146b97..03db6e4d92cb3b62ac3d8b3cbd97783817c6326b 100644
13--- a/llvm/include/llvm/Support/MathExtras.h
14+++ b/llvm/include/llvm/Support/MathExtras.h
15@@ -356,7 +356,10 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align) {
16 inline uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align) {
17 assert(Align != 0 && (Align & (Align - 1)) == 0 &&
18 "Align must be a power of 2");
19- return (Value + Align - 1) & -Align;
20+ // Replace unary minus to avoid compilation error on Windows:
21+ // "unary minus operator applied to unsigned type, result still unsigned"
22+ uint64_t negAlign = (~Align) + 1;
23+ return (Value + Align - 1) & negAlign;
24 }
25
26 /// If non-zero \p Skew is specified, the return value will be a minimal integer