Skip to content

Commit 2d51705

Browse files
authored
[webkit.UncountedLambdaCapturesChecker] Assertion failure with coroutine body (#165650)
Fix the assertion failure in TrivialFunctionAnalysis::isTrivialImpl with a coroutine body by caching the result with WithCachedResult.
1 parent 9fc8ddd commit 2d51705

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ class TrivialFunctionAnalysisVisitor
578578
return WithCachedResult(CS, [&]() { return VisitChildren(CS); });
579579
}
580580

581+
bool VisitCoroutineBodyStmt(const CoroutineBodyStmt *CBS) {
582+
return WithCachedResult(CBS, [&]() { return VisitChildren(CBS); });
583+
}
584+
581585
bool VisitReturnStmt(const ReturnStmt *RS) {
582586
// A return statement is allowed as long as the return value is trivial.
583587
if (auto *RV = RS->getRetValue())
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.UncountedLambdaCapturesChecker -std=c++20 -verify %s
2+
// expected-no-diagnostics
3+
4+
template<typename Arg>
5+
void foo(Arg&& arg)
6+
{
7+
[&]{
8+
co_await [&](auto&&... args) {
9+
}(arg);
10+
}();
11+
}

0 commit comments

Comments
 (0)