Skip to content

[webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings #108656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
@@ -72,25 +72,32 @@ class DerefFuncDeleteExprVisitor
if (name == "ensureOnMainThread" || name == "ensureOnMainRunLoop") {
for (unsigned i = 0; i < CE->getNumArgs(); ++i) {
auto *Arg = CE->getArg(i);
if (VisitLabmdaArgument(Arg))
if (VisitLambdaArgument(Arg))
return true;
}
}
}
return false;
}

bool VisitLabmdaArgument(const Expr *E) {
bool VisitLambdaArgument(const Expr *E) {
E = E->IgnoreParenCasts();
if (auto *TempE = dyn_cast<CXXBindTemporaryExpr>(E))
E = TempE->getSubExpr();
E = E->IgnoreParenCasts();
if (auto *Ref = dyn_cast<DeclRefExpr>(E)) {
if (auto *VD = dyn_cast_or_null<VarDecl>(Ref->getDecl()))
return VisitLambdaArgument(VD->getInit());
return false;
}
if (auto *Lambda = dyn_cast<LambdaExpr>(E)) {
if (VisitBody(Lambda->getBody()))
return true;
}
if (auto *ConstructE = dyn_cast<CXXConstructExpr>(E)) {
for (unsigned i = 0; i < ConstructE->getNumArgs(); ++i) {
auto *Arg = ConstructE->getArg(i);
if (auto *Lambda = dyn_cast<LambdaExpr>(Arg)) {
if (VisitBody(Lambda->getBody()))
return true;
}
if (VisitLambdaArgument(ConstructE->getArg(i)))
return true;
}
}
return false;
Original file line number Diff line number Diff line change
@@ -119,6 +119,11 @@ template<class T, DestructionThread destructionThread = DestructionThread::Any>
ensureOnMainThread([this] {
delete static_cast<const T*>(this);
});
} else if constexpr (destructionThread == DestructionThread::MainRunLoop) {
auto deleteThis = [this] {
delete static_cast<const T*>(this);
};
ensureOnMainThread(deleteThis);
}
}

@@ -230,3 +235,16 @@ class FancyRefCountedClass4 final : public BadNestedThreadSafeRefCounted<FancyRe
private:
FancyRefCountedClass4();
};

class FancyRefCountedClass5 final : public ThreadSafeRefCounted<FancyRefCountedClass5, DestructionThread::MainRunLoop> {
public:
static Ref<FancyRefCountedClass5> create()
{
return adoptRef(*new FancyRefCountedClass5());
}

virtual ~FancyRefCountedClass5();

private:
FancyRefCountedClass5();
};
Loading