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
202
202
if (!C)
203
203
continue ;
204
204
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
+
205
212
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(C)) {
206
213
for (auto &Arg : CTSD->getTemplateArgs ().asArray ()) {
207
214
if (Arg.getKind () != TemplateArgument::Type)
@@ -223,12 +230,13 @@ class RefCntblBaseVirtualDtorChecker
223
230
224
231
llvm::SetVector<const CXXRecordDecl *> Decls;
225
232
llvm::DenseSet<const CXXRecordDecl *> CRTPs;
233
+ llvm::DenseSet<const CXXRecordDecl *> ExemptDecls;
226
234
};
227
235
228
236
LocalVisitor visitor (this );
229
237
visitor.TraverseDecl (const_cast <TranslationUnitDecl *>(TUD));
230
238
for (auto *RD : visitor.Decls ) {
231
- if (visitor.CRTPs .contains (RD))
239
+ if (visitor.CRTPs .contains (RD) || visitor. ExemptDecls . contains (RD) )
232
240
continue ;
233
241
visitCXXRecordDecl (RD);
234
242
}
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.RefCntblBaseVirtualDtor -verify %s
2
2
3
+ namespace WTF {
4
+
5
+ class NoVirtualDestructorBase { };
6
+
7
+ };
8
+
9
+ using WTF::NoVirtualDestructorBase;
10
+
3
11
struct RefCntblBase {
4
12
void ref () {}
5
13
void deref () {}
@@ -19,6 +27,15 @@ struct [[clang::suppress]] SuppressedDerivedWithVirtualDtor : RefCntblBase {
19
27
virtual ~SuppressedDerivedWithVirtualDtor () {}
20
28
};
21
29
30
+ class ClassWithoutVirtualDestructor : public NoVirtualDestructorBase {
31
+ public:
32
+ void ref () const ;
33
+ void deref () const ;
34
+ };
35
+
36
+ class DerivedClassWithoutVirtualDestructor : public ClassWithoutVirtualDestructor {
37
+ };
38
+
22
39
// FIXME: Support attributes on base specifiers? Currently clang
23
40
// doesn't support such attributes at all, even though it knows
24
41
// how to parse them.
You can’t perform that action at this time.
0 commit comments