Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ class UncountedLambdaCapturesChecker
bool VisitCallExpr(CallExpr *CE) override {
checkCalleeLambda(CE);
if (auto *Callee = CE->getDirectCallee()) {
bool TreatAllArgsAsNoEscape = shouldTreatAllArgAsNoEscape(Callee);
unsigned ArgIndex = 0;
if (auto *CXXCallee = dyn_cast<CXXMethodDecl>(Callee))
ArgIndex = CXXCallee->isInstance();
bool TreatAllArgsAsNoEscape = shouldTreatAllArgAsNoEscape(Callee);
for (auto *Param : Callee->parameters()) {
if (ArgIndex >= CE->getNumArgs())
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,22 @@ struct RefCountableWithLambdaCapturingThis {
call(lambda);
}

void method_captures_this_with_guardian_refPtr() {
void method_captures_this_with_guardian_refptr() {
auto lambda = [this, protectedThis = RefPtr { &*this }]() {
nonTrivial();
};
call(lambda);
}

void forEach(const WTF::Function<void(RefCountable&)>&);
void method_captures_this_with_lambda_with_no_escape() {
auto run = [&]([[clang::noescape]] const WTF::Function<void(RefCountable&)>& func) {
forEach(func);
};
run([&](RefCountable&) {
nonTrivial();
});
}
};

struct NonRefCountableWithLambdaCapturingThis {
Expand Down