[llvm] fix build error in MSVC build (PR #86622)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 22:53:44 PDT 2024


https://github.com/SevenIsSeven updated https://github.com/llvm/llvm-project/pull/86622

>From 3094482cbf07a52cd651dc786e9de6bd67fbcfae Mon Sep 17 00:00:00 2001
From: Seven <Seven.Li at amd.com>
Date: Tue, 26 Mar 2024 11:52:09 +0900
Subject: [PATCH 1/3] fix build error in MSVC build

This commit(https://github.com/llvm/llvm-project/pull/84738) introduced
following compile warning then treated-as-error in MSVC build.

>>>"'^': unsafe mix of type 'unsigned int' and type 'bool' in operation"
---
 llvm/include/llvm/IR/BasicBlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 0eea4cdccca5bb..ca87e40727c71d 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -791,7 +791,7 @@ template <> struct DenseMapInfo<BasicBlock::iterator> {
   static unsigned getHashValue(const BasicBlock::iterator &It) {
     return DenseMapInfo<void *>::getHashValue(
                reinterpret_cast<void *>(It.getNodePtr())) ^
-           It.getHeadBit();
+           (int) It.getHeadBit();
   }
 
   static bool isEqual(const BasicBlock::iterator &LHS,

>From fe9b0c270149499d1677fadae335c58e3934c82d Mon Sep 17 00:00:00 2001
From: Seven <Seven.Li at amd.com>
Date: Tue, 26 Mar 2024 12:39:45 +0900
Subject: [PATCH 2/3] correct the clang-format style.

---
 llvm/include/llvm/IR/BasicBlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index ca87e40727c71d..a36a35cab8966d 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -791,7 +791,7 @@ template <> struct DenseMapInfo<BasicBlock::iterator> {
   static unsigned getHashValue(const BasicBlock::iterator &It) {
     return DenseMapInfo<void *>::getHashValue(
                reinterpret_cast<void *>(It.getNodePtr())) ^
-           (int) It.getHeadBit();
+           (int)It.getHeadBit();
   }
 
   static bool isEqual(const BasicBlock::iterator &LHS,

>From 4cea45b3a962b2a819aa7f83e234ffe90c5bd90e Mon Sep 17 00:00:00 2001
From: Seven <Seven.Li at amd.com>
Date: Tue, 26 Mar 2024 14:53:00 +0900
Subject: [PATCH 3/3] use a better type name

---
 llvm/include/llvm/IR/BasicBlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index a36a35cab8966d..0c5a07bde4ecf0 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -791,7 +791,7 @@ template <> struct DenseMapInfo<BasicBlock::iterator> {
   static unsigned getHashValue(const BasicBlock::iterator &It) {
     return DenseMapInfo<void *>::getHashValue(
                reinterpret_cast<void *>(It.getNodePtr())) ^
-           (int)It.getHeadBit();
+           (unsigned)It.getHeadBit();
   }
 
   static bool isEqual(const BasicBlock::iterator &LHS,



More information about the llvm-commits mailing list