xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/modernize/use-override-templates.cpp (revision 1af159e98c23a293c103e1f548866488126ed6f6)
195564099SPiotr Zegar // RUN: %check_clang_tidy %s modernize-use-override %t -- \
2*1af159e9SPiotr Zegar // RUN:   -config="{CheckOptions: {modernize-use-override.IgnoreTemplateInstantiations: true}}"
395564099SPiotr Zegar 
495564099SPiotr Zegar struct Base {
595564099SPiotr Zegar   virtual void foo();
695564099SPiotr Zegar };
795564099SPiotr Zegar 
895564099SPiotr Zegar struct Base2 {
995564099SPiotr Zegar   virtual void foo2();
1095564099SPiotr Zegar };
1195564099SPiotr Zegar 
1295564099SPiotr Zegar template<typename T>
1395564099SPiotr Zegar struct Derived : T {
1495564099SPiotr Zegar   // should not warn, comes from template instance
1595564099SPiotr Zegar   virtual void foo();
1695564099SPiotr Zegar   virtual void foo2();
1795564099SPiotr Zegar };
1895564099SPiotr Zegar 
test()1995564099SPiotr Zegar void test() {
2095564099SPiotr Zegar   Derived<Base> b;
2195564099SPiotr Zegar   Derived<Base2> b2;
2295564099SPiotr Zegar }
2395564099SPiotr Zegar 
2495564099SPiotr Zegar template<typename T>
2595564099SPiotr Zegar struct BaseS {
2695564099SPiotr Zegar   virtual void boo();
2795564099SPiotr Zegar };
2895564099SPiotr Zegar 
2995564099SPiotr Zegar template<>
3095564099SPiotr Zegar struct BaseS<int> {
3195564099SPiotr Zegar   virtual void boo2();
3295564099SPiotr Zegar };
3395564099SPiotr Zegar 
3495564099SPiotr Zegar struct BaseU {
3595564099SPiotr Zegar   virtual void boo3();
3695564099SPiotr Zegar };
3795564099SPiotr Zegar 
3895564099SPiotr Zegar template<typename T>
3995564099SPiotr Zegar struct Derived2 : BaseS<T>, BaseU {
4095564099SPiotr Zegar   // should not warn, comes from template instance
4195564099SPiotr Zegar   virtual void boo();
4295564099SPiotr Zegar   virtual void boo2();
4395564099SPiotr Zegar   // should warn, comes from non-template BaseU
4495564099SPiotr Zegar   virtual void boo3();
4595564099SPiotr Zegar   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
4695564099SPiotr Zegar   // CHECK-FIXES: {{^  }}void boo3() override;
4795564099SPiotr Zegar };
48