File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,13 @@ class RefCntblBaseVirtualDtorChecker
202202 if (!C)
203203 continue ;
204204
205+ bool isExempt = T.getAsString () == " NoVirtualDestructorBase" &&
206+ safeGetName (C->getParent ()) == " WTF" ;
207+ if (isExempt || ExemptDecls.contains (C)) {
208+ ExemptDecls.insert (RD);
209+ continue ;
210+ }
211+
205212 if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(C)) {
206213 for (auto &Arg : CTSD->getTemplateArgs ().asArray ()) {
207214 if (Arg.getKind () != TemplateArgument::Type)
@@ -223,12 +230,13 @@ class RefCntblBaseVirtualDtorChecker
223230
224231 llvm::SetVector<const CXXRecordDecl *> Decls;
225232 llvm::DenseSet<const CXXRecordDecl *> CRTPs;
233+ llvm::DenseSet<const CXXRecordDecl *> ExemptDecls;
226234 };
227235
228236 LocalVisitor visitor (this );
229237 visitor.TraverseDecl (const_cast <TranslationUnitDecl *>(TUD));
230238 for (auto *RD : visitor.Decls ) {
231- if (visitor.CRTPs .contains (RD))
239+ if (visitor.CRTPs .contains (RD) || visitor. ExemptDecls . contains (RD) )
232240 continue ;
233241 visitCXXRecordDecl (RD);
234242 }
Original file line number Diff line number Diff line change 11// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.RefCntblBaseVirtualDtor -verify %s
22
3+ namespace WTF {
4+
5+ class NoVirtualDestructorBase { };
6+
7+ };
8+
9+ using WTF::NoVirtualDestructorBase;
10+
311struct RefCntblBase {
412 void ref () {}
513 void deref () {}
@@ -19,6 +27,15 @@ struct [[clang::suppress]] SuppressedDerivedWithVirtualDtor : RefCntblBase {
1927 virtual ~SuppressedDerivedWithVirtualDtor () {}
2028};
2129
30+ class ClassWithoutVirtualDestructor : public NoVirtualDestructorBase {
31+ public:
32+ void ref () const ;
33+ void deref () const ;
34+ };
35+
36+ class DerivedClassWithoutVirtualDestructor : public ClassWithoutVirtualDestructor {
37+ };
38+
2239// FIXME: Support attributes on base specifiers? Currently clang
2340// doesn't support such attributes at all, even though it knows
2441// how to parse them.
You can’t perform that action at this time.
0 commit comments