| 1 | // RUN: %check_clang_tidy %s misc-use-internal-linkage %t -- -- -I%S/Inputs/use-internal-linkage |
| 2 | // RUN: %check_clang_tidy %s misc-use-internal-linkage %t -- \ |
| 3 | // RUN: -config="{CheckOptions: {misc-use-internal-linkage.FixMode: 'UseStatic'}}" -- -I%S/Inputs/use-internal-linkage |
| 4 | |
| 5 | #include "var.h" |
| 6 | |
| 7 | int global; |
| 8 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'global' |
| 9 | // CHECK-FIXES: static int global; |
| 10 | |
| 11 | template<class T> |
| 12 | T global_template; |
| 13 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: variable 'global_template' |
| 14 | // CHECK-FIXES: static T global_template; |
| 15 | |
| 16 | int const* ptr_const_star; |
| 17 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'ptr_const_star' |
| 18 | // CHECK-FIXES: static int const* ptr_const_star; |
| 19 | |
| 20 | const int* const_ptr_star; |
| 21 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'const_ptr_star' |
| 22 | // CHECK-FIXES: static const int* const_ptr_star; |
| 23 | |
| 24 | const volatile int* const_volatile_ptr_star; |
| 25 | // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: variable 'const_volatile_ptr_star' |
| 26 | // CHECK-FIXES: static const volatile int* const_volatile_ptr_star; |
| 27 | |
| 28 | int ; |
| 29 | |
| 30 | extern int global_extern; |
| 31 | |
| 32 | static int global_static; |
| 33 | |
| 34 | thread_local int global_thread_local; |
| 35 | |
| 36 | namespace { |
| 37 | static int global_anonymous_ns; |
| 38 | namespace NS { |
| 39 | static int global_anonymous_ns; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | static void f(int para) { |
| 44 | int local; |
| 45 | static int local_static; |
| 46 | thread_local int local_thread_local; |
| 47 | } |
| 48 | |
| 49 | struct S { |
| 50 | int m1; |
| 51 | static int m2; |
| 52 | }; |
| 53 | int S::m2; |
| 54 | |
| 55 | extern "C" { |
| 56 | int global_in_extern_c_1; |
| 57 | } |
| 58 | |
| 59 | extern "C" int global_in_extern_c_2; |
| 60 | |
| 61 | const int const_global = 123; |
| 62 | constexpr int constexpr_global = 123; |
| 63 | |