[llvm] [llvm][NFC] add -Wparentheses suggestion in assert statement (PR #213477)

Hardik Kumar via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 1 11:44:29 PDT 2026


https://github.com/hardikxk created https://github.com/llvm/llvm-project/pull/213477

Add parenthesis in an assert expression as per the warning below.

```bash
/home/xane/Documents/shallowllvm/llvm-project/llvm/lib/Analysis/AssumptionCache.cpp:169:18: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  169 |            Found && "already unregistered or incorrect cache state");
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

The patch helps to make it more obvious that the AND part will execute first, and also improves the readibilty of the code, and results in one less warning.

>From 286b82de4b9e8bcbed79f2817afc7cd12ce59247 Mon Sep 17 00:00:00 2001
From: Hardik Kumar <hardikxk at gmail.com>
Date: Sun, 2 Aug 2026 00:05:41 +0530
Subject: [PATCH] [llvm][NFC] add -Wparentheses suggestion in assert statement
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add parenthesis in an assert expression as per the warning below.

```bash
/llvm/lib/Analysis/AssumptionCache.cpp:169:18: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  169 |            Found && "already unregistered or incorrect cache state");
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

The patch helps to make it more obvious that the AND part will execute first, and
also improves the readibilty of the code, and results in one less warning.
---
 llvm/lib/Analysis/AssumptionCache.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Analysis/AssumptionCache.cpp b/llvm/lib/Analysis/AssumptionCache.cpp
index 0794d83a844e2..683b15910e902 100644
--- a/llvm/lib/Analysis/AssumptionCache.cpp
+++ b/llvm/lib/Analysis/AssumptionCache.cpp
@@ -166,7 +166,7 @@ void AssumptionCache::removeAffectedValues(AssumeInst *CI) {
     }
 
     assert(ExpectedMatches[AV.Assume] == 0 ||
-           Found && "already unregistered or incorrect cache state");
+           (Found && "already unregistered or incorrect cache state"));
 
     if (!HasNonnull)
       AffectedValues.erase(AVI);



More information about the llvm-commits mailing list