[llvm-branch-commits] [clang] release/21.x: [analyzer] Add missing expected-warning after #151908 (PR #155284)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 25 12:47:38 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (llvmbot)

<details>
<summary>Changes</summary>

Backport 0a1eff2ecedcb11acb3e9d4b75ee1e1bebd69a70 6c9f1ce429809e5a91683ed6cef9a435047bebd1

Requested by: @<!-- -->steakhal

---
Full diff: https://github.com/llvm/llvm-project/pull/155284.diff


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp (-1) 
- (modified) clang/test/Analysis/cxx23-assume-attribute.cpp (+6) 


``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp
index 1e3adb4f266ca..789c7772d123a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp
@@ -45,7 +45,6 @@ void AssumeModelingChecker::checkPostStmt(const AttributedStmt *A,
       continue;
 
     const auto *Assumption = AssumptionVal.getAsInteger();
-    assert(Assumption && "We should know the exact outcome of an assume expr");
     if (Assumption && Assumption->isZero()) {
       C.addSink();
     }
diff --git a/clang/test/Analysis/cxx23-assume-attribute.cpp b/clang/test/Analysis/cxx23-assume-attribute.cpp
index 86e7662cd2af9..4cc16446572dc 100644
--- a/clang/test/Analysis/cxx23-assume-attribute.cpp
+++ b/clang/test/Analysis/cxx23-assume-attribute.cpp
@@ -69,3 +69,9 @@ int assume_and_fallthrough_at_the_same_attrstmt(int a, int b) {
 
   return 0;
 }
+
+void assume_opaque_gh151854_no_crash() {
+  extern bool opaque();
+  [[assume(opaque())]]; // no-crash
+  // expected-warning at -1 {{assumption is ignored because it contains (potential) side-effects}}
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/155284


More information about the llvm-branch-commits mailing list