Debian Codegraph @

clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor.cpp

raw
1 // RUN: %clang_analyze_cc1 -analyzer-checker=webkit.RefCntblBaseVirtualDtor -verify %s
2
3 struct RefCntblBase {
4 void ref() {}
5 void deref() {}
6 };
7
8 struct Derived : RefCntblBase { };
9 // expected-warning@-1{{Struct 'RefCntblBase' is used as a base of struct 'Derived' but doesn't have virtual destructor}}
10
11 struct DerivedWithVirtualDtor : RefCntblBase {
12 // expected-warning@-1{{Struct 'RefCntblBase' is used as a base of struct 'DerivedWithVirtualDtor' but doesn't have virtual destructor}}
13 virtual ~DerivedWithVirtualDtor() {}
14 };
15
16 // Confirm that the checker respects [[clang::suppress]]
17 struct [[clang::suppress]] SuppressedDerived : RefCntblBase { };
18 struct [[clang::suppress]] SuppressedDerivedWithVirtualDtor : RefCntblBase {
19 virtual ~SuppressedDerivedWithVirtualDtor() {}
20 };
21
22 // FIXME: Support attributes on base specifiers? Currently clang
23 // doesn't support such attributes at all, even though it knows
24 // how to parse them.
25 //
26 // struct SuppressedBaseSpecDerived : [[clang::suppress]] RefCntblBase { };
27
28 template<class T>
29 struct DerivedClassTmpl : T { };
30 typedef DerivedClassTmpl<RefCntblBase> Foo;
31
32
33
34 struct RandomBase {};
35 struct RandomDerivedClass : RandomBase { };
36
37
38
39 struct FakeRefCntblBase1 {
40 private:
41 void ref() {}
42 void deref() {}
43 };
44 struct Quiet1 : FakeRefCntblBase1 {};
45
46 struct FakeRefCntblBase2 {
47 protected:
48 void ref() {}
49 void deref() {}
50 };
51 struct Quiet2 : FakeRefCntblBase2 {};
52
53 class FakeRefCntblBase3 {
54 void ref() {}
55 void deref() {}
56 };
57 struct Quiet3 : FakeRefCntblBase3 {};
58 struct Quiet4 : private RefCntblBase {};
59 class Quiet5 : RefCntblBase {};
60
61 void foo () {
62 Derived d;
63 }