[llvm] [NFC] Fix unary minus operator on unsigned type warning (PR #153887)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 17 16:30:03 PDT 2025


https://github.com/Nadharm updated https://github.com/llvm/llvm-project/pull/153887

>From 238fe271f392ce70bb20dce3c11a43bc113c6773 Mon Sep 17 00:00:00 2001
From: Nadharm Dhiantravan <ndhiantravan at nvidia.com>
Date: Wed, 18 Jun 2025 07:45:51 -0700
Subject: [PATCH] [NFC] Fix unary minus operator on unsigned type warning

Fixes:
warning C4146: unary minus operator applied to unsigned type, result still unsigned
---
 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 c24f01fe26cc8..533808e0666d5 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -68,7 +68,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
   // Allow Function to renumber blocks.
   friend class Function;
   /// Per-function unique number.
-  unsigned Number = -1u;
+  unsigned Number = ~0u;
 
   friend class BlockAddress;
   friend class SymbolTableListTraits<BasicBlock>;



More information about the llvm-commits mailing list