-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[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
[webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings #108656
Conversation
… warnings Improve the fix in 203a2ca by allowing variable references and more ignoring of parentheses.
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-static-analyzer-1 Author: Ryosuke Niwa (rniwa) ChangesImprove the fix in 203a2ca by allowing variable references and more ignoring of parentheses. Full diff: https://github.com/llvm/llvm-project/pull/108656.diff 2 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
index ecba5f9aa23ee3..5ea19233bb65c2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
@@ -84,13 +84,22 @@ class DerefFuncDeleteExprVisitor
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 *Decl = Ref->getDecl()) {
+ if (auto *VD = dyn_cast<VarDecl>(Decl))
+ return VisitLabmdaArgument(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 (VisitLabmdaArgument(ConstructE->getArg(i)))
+ return true;
}
}
return false;
diff --git a/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp b/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
index 01527addb52992..33c60ea8ca64d1 100644
--- a/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
@@ -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();
+};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
Outdated
Show resolved
Hide resolved
clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
Outdated
Show resolved
Hide resolved
clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
Show resolved
Hide resolved
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/6407 Here is the relevant piece of the build log for the reference
|
… warnings (llvm#108656) Improve the fix in 203a2ca by allowing variable references and more ignoring of parentheses.
… warnings (llvm#108656) Improve the fix in 203a2ca by allowing variable references and more ignoring of parentheses.
… warnings (llvm#108656) Improve the fix in 203a2ca by allowing variable references and more ignoring of parentheses.
Improve the fix in 203a2ca by allowing variable references and more ignoring of parentheses.