[llvm] [NFC] [DirectX] Fix warning about parentheses for assertion in DXContainerGlobals.cpp (PR #166231)

Deric C. via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 12:40:31 PST 2025


https://github.com/Icohedron created https://github.com/llvm/llvm-project/pull/166231

This PR fixes the appearance of the following warning message when building LLVM with clang (21.1.2)
```
[48/100] Building CXX object lib/Target/DirectX/CMakeFiles/LLVMDirectXCodeGen.dir/DXContainerGlobals.cpp.o
In file included from /nix/store/ffrg0560kj0066s4k9pznjand907nlnz-gcc-14.3.0/include/c++/14.3.0/cassert:44,
                 from /workspace/llvm-project/llvm/include/llvm/Support/Endian.h:19,
                 from /workspace/llvm-project/llvm/include/llvm/Support/MD5.h:33,
                 from /workspace/llvm-project/llvm/lib/Target/DirectX/DXContainerGlobals.cpp:28:
/workspace/llvm-project/llvm/lib/Target/DirectX/DXContainerGlobals.cpp: In lambda function:
/workspace/llvm-project/llvm/lib/Target/DirectX/DXContainerGlobals.cpp:198:78: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  198 |                (uint64_t)Binding.LowerBound + Binding.Size - 1 <= UINT32_MAX &&
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  199 |                    "Resource range is too large");
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ```
 
 I marked this PR as an NFC because it only modifies an assertion condition to remove a compiler warning.

>From 53b19a7e45c8121f697b41f75dd9823f5f657628 Mon Sep 17 00:00:00 2001
From: Deric Cheung <cheung.deric at gmail.com>
Date: Mon, 3 Nov 2025 12:36:11 -0800
Subject: [PATCH] Fix warning about parentheses around '&&' within '||'

---
 llvm/lib/Target/DirectX/DXContainerGlobals.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index 8ace2d2777c74..eb4c8846441a2 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
@@ -194,9 +194,10 @@ void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
         dxbc::PSV::v2::ResourceBindInfo BindInfo;
         BindInfo.Type = Type;
         BindInfo.LowerBound = Binding.LowerBound;
-        assert(Binding.Size == UINT32_MAX ||
-               (uint64_t)Binding.LowerBound + Binding.Size - 1 <= UINT32_MAX &&
-                   "Resource range is too large");
+        assert(
+            (Binding.Size == UINT32_MAX ||
+             (uint64_t)Binding.LowerBound + Binding.Size - 1 <= UINT32_MAX) &&
+            "Resource range is too large");
         BindInfo.UpperBound = (Binding.Size == UINT32_MAX)
                                   ? UINT32_MAX
                                   : Binding.LowerBound + Binding.Size - 1;



More information about the llvm-commits mailing list