https://github.com/rniwa created 
https://github.com/llvm/llvm-project/pull/165650

Fix the assertion failure in TrivialFunctionAnalysis::isTrivialImpl with a 
coroutine body by caching the result with WithCachedResult.

>From da02273e8a53733de4b40cc21478ca7c31d2c4a7 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa <[email protected]>
Date: Wed, 29 Oct 2025 22:21:47 -0700
Subject: [PATCH] [webkit.UncountedLambdaCapturesChecker] Assertion failure
 with coroutine body

Fix the assertion failure in TrivialFunctionAnalysis::isTrivialImpl with
a coroutine body by caching the result with WithCachedResult.
---
 .../Checkers/WebKit/PtrTypesSemantics.cpp             |  4 ++++
 ...ted-lambda-captures-co_await-assertion-failure.cpp | 11 +++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 
clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures-co_await-assertion-failure.cpp

diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index d3d1f13ab1c78..5cd894af1fd65 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -578,6 +578,10 @@ class TrivialFunctionAnalysisVisitor
     return WithCachedResult(CS, [&]() { return VisitChildren(CS); });
   }
 
+  bool VisitCoroutineBodyStmt(const CoroutineBodyStmt *CBS) {
+    return WithCachedResult(CBS, [&]() { return VisitChildren(CBS); });
+  }
+
   bool VisitReturnStmt(const ReturnStmt *RS) {
     // A return statement is allowed as long as the return value is trivial.
     if (auto *RV = RS->getRetValue())
diff --git 
a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures-co_await-assertion-failure.cpp
 
b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures-co_await-assertion-failure.cpp
new file mode 100644
index 0000000000000..a67f45700cd10
--- /dev/null
+++ 
b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures-co_await-assertion-failure.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_analyze_cc1 
-analyzer-checker=webkit.UncountedLambdaCapturesChecker -std=c++20 -verify %s
+// expected-no-diagnostics
+
+template<typename Arg>
+void foo(Arg&& arg)
+{
+    [&]{
+        co_await [&](auto&&... args) {
+        }(arg);
+    }();
+}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to