1 // RUN: %clang_analyze_cc1 -analyzer-checker=webkit.RefCntblBaseVirtualDtor -verify %s 2 3 struct RefCntblBase { refRefCntblBase4 void ref() {} derefRefCntblBase5 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}} ~DerivedWithVirtualDtorDerivedWithVirtualDtor13 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: refFakeRefCntblBase131 void ref() {} derefFakeRefCntblBase132 void deref() {} 33 }; 34 struct Quiet1 : FakeRefCntblBase1 {}; 35 36 struct FakeRefCntblBase2 { 37 protected: refFakeRefCntblBase238 void ref() {} derefFakeRefCntblBase239 void deref() {} 40 }; 41 struct Quiet2 : FakeRefCntblBase2 {}; 42 43 class FakeRefCntblBase3 { ref()44 void ref() {} deref()45 void deref() {} 46 }; 47 struct Quiet3 : FakeRefCntblBase3 {}; 48 struct Quiet4 : private RefCntblBase {}; 49 class Quiet5 : RefCntblBase {}; 50 foo()51void foo () { 52 Derived d; 53 } 54