brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · abf95b8 Raw
98 lines · cpp
1// RUN: %check_clang_tidy %s misc-use-internal-linkage %t -- -- -I%S/Inputs/use-internal-linkage2// 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-linkage4 5#include "func.h"6 7void func() {}8// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'func'9// CHECK-FIXES: static void func() {}10 11template<class T>12void func_template() {}13// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'func_template'14// CHECK-FIXES: static void func_template() {}15 16void func_cpp_inc() {}17// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'func_cpp_inc'18// CHECK-FIXES: static void func_cpp_inc() {}19 20int* func_cpp_inc_return_ptr() { return nullptr; }21// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'func_cpp_inc_return_ptr'22// CHECK-FIXES: static int* func_cpp_inc_return_ptr() { return nullptr; }23 24const int* func_cpp_inc_return_const_ptr() { return nullptr; }25// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: function 'func_cpp_inc_return_const_ptr'26// CHECK-FIXES: static const int* func_cpp_inc_return_const_ptr() { return nullptr; }27 28int const* func_cpp_inc_return_ptr_const() { return nullptr; }29// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: function 'func_cpp_inc_return_ptr_const'30// CHECK-FIXES: static int const* func_cpp_inc_return_ptr_const() { return nullptr; }31 32int * const func_cpp_inc_return_const() { return nullptr; }33// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function 'func_cpp_inc_return_const'34// CHECK-FIXES: static int * const func_cpp_inc_return_const() { return nullptr; }35 36volatile const int* func_cpp_inc_return_volatile_const_ptr() { return nullptr; }37// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: function 'func_cpp_inc_return_volatile_const_ptr'38// CHECK-FIXES: static volatile const int* func_cpp_inc_return_volatile_const_ptr() { return nullptr; }39 40[[nodiscard]] void func_nodiscard() {}41// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: function 'func_nodiscard'42// CHECK-FIXES: {{\[\[nodiscard\]\]}} static void func_nodiscard() {}43 44#define NDS [[nodiscard]]45#define NNDS46 47NDS void func_nds() {}48// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function 'func_nds'49// CHECK-FIXES: NDS static void func_nds() {}50 51NNDS void func_nnds() {}52// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'func_nnds'53// CHECK-FIXES: NNDS static void func_nnds() {}54 55#include "func_cpp.inc"56 57void func_h_inc() {}58 59struct S {60  void method();61};62void S::method() {}63 64void func_header() {}65extern void func_extern() {}66static void func_static() {}67namespace {68void func_anonymous_ns() {}69} // namespace70 71int main(int argc, const char*argv[]) {}72 73extern "C" {74void func_extern_c_1() {}75}76 77extern "C" void func_extern_c_2() {}78 79namespace gh117488 {80void func_with_body();81// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'func_with_body'82// CHECK-FIXES: static void func_with_body();83void func_with_body() {}84 85void func_without_body();86void func_without_body();87}88 89// gh117489 start90namespace std {91using size_t = decltype(sizeof(int));92}93void * operator new(std::size_t) { return nullptr; }94void * operator new[](std::size_t) { return nullptr; }95void operator delete(void*) noexcept {}96void operator delete[](void*) noexcept {}97// gh117489 end98