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 @@ -203,6 +203,13 @@ class RefCntblBaseVirtualDtorChecker
203203 if (!C)
204204 continue ;
205205
206+ bool isExempt = T.getAsString () == " NoVirtualDestructorBase" &&
207+ safeGetName (C->getParent ()) == " WTF" ;
208+ if (isExempt || ExemptDecls.contains (C)) {
209+ ExemptDecls.insert (RD);
210+ continue ;
211+ }
212+
206213 if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(C)) {
207214 for (auto &Arg : CTSD->getTemplateArgs ().asArray ()) {
208215 if (Arg.getKind () != TemplateArgument::Type)
@@ -224,12 +231,13 @@ class RefCntblBaseVirtualDtorChecker
224231
225232 llvm::SetVector<const CXXRecordDecl *> Decls;
226233 llvm::DenseSet<const CXXRecordDecl *> CRTPs;
234+ llvm::DenseSet<const CXXRecordDecl *> ExemptDecls;
227235 };
228236
229237 LocalVisitor visitor (this );
230238 visitor.TraverseDecl (const_cast <TranslationUnitDecl *>(TUD));
231239 for (auto *RD : visitor.Decls ) {
232- if (visitor.CRTPs .contains (RD))
240+ if (visitor.CRTPs .contains (RD) || visitor. ExemptDecls . contains (RD) )
233241 continue ;
234242 visitCXXRecordDecl (RD);
235243 }
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