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 17 18 template<class T> 19 struct DerivedClassTmpl : T { }; 20 typedef DerivedClassTmpl<RefCntblBase> Foo; 21 22 23 24 struct RandomBase {}; 25 struct RandomDerivedClass : RandomBase { }; 26 27 28 29 struct FakeRefCntblBase1 { 30 private: 31 void ref() {} 32 void deref() {} 33 }; 34 struct Quiet1 : FakeRefCntblBase1 {}; 35 36 struct FakeRefCntblBase2 { 37 protected: 38 void ref() {} 39 void deref() {} 40 }; 41 struct Quiet2 : FakeRefCntblBase2 {}; 42 43 class FakeRefCntblBase3 { 44 void ref() {} 45 void deref() {} 46 }; 47 struct Quiet3 : FakeRefCntblBase3 {}; 48 struct Quiet4 : private RefCntblBase {}; 49 class Quiet5 : RefCntblBase {}; 50 51 void foo () { 52 Derived d; 53 } 54