File tree 2 files changed +26
-1
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,13 @@ class RefCntblBaseVirtualDtorChecker
203
203
if (!C)
204
204
continue ;
205
205
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
+
206
213
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(C)) {
207
214
for (auto &Arg : CTSD->getTemplateArgs ().asArray ()) {
208
215
if (Arg.getKind () != TemplateArgument::Type)
@@ -224,12 +231,13 @@ class RefCntblBaseVirtualDtorChecker
224
231
225
232
llvm::SetVector<const CXXRecordDecl *> Decls;
226
233
llvm::DenseSet<const CXXRecordDecl *> CRTPs;
234
+ llvm::DenseSet<const CXXRecordDecl *> ExemptDecls;
227
235
};
228
236
229
237
LocalVisitor visitor (this );
230
238
visitor.TraverseDecl (const_cast <TranslationUnitDecl *>(TUD));
231
239
for (auto *RD : visitor.Decls ) {
232
- if (visitor.CRTPs .contains (RD))
240
+ if (visitor.CRTPs .contains (RD) || visitor. ExemptDecls . contains (RD) )
233
241
continue ;
234
242
visitCXXRecordDecl (RD);
235
243
}
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