Skip to content

Commit b7ca052

Browse files
committed
[webkit.UncountedLambdaCapturesChecker] Assertion failure with coroutine body (llvm#165650)
Fix the assertion failure in TrivialFunctionAnalysis::isTrivialImpl with a coroutine body by caching the result with WithCachedResult. (cherry picked from commit 2d51705)
1 parent a9734be commit b7ca052

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
@@ -591,6 +591,10 @@ class TrivialFunctionAnalysisVisitor
591591
return WithCachedResult(CS, [&]() { return VisitChildren(CS); });
592592
}
593593

594+
bool VisitCoroutineBodyStmt(const CoroutineBodyStmt *CBS) {
595+
return WithCachedResult(CBS, [&]() { return VisitChildren(CBS); });
596+
}
597+
594598
bool VisitReturnStmt(const ReturnStmt *RS) {
595599
// A return statement is allowed as long as the return value is trivial.
596600
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)