xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/google/objc-function-naming.m (revision 89a1d03e2b379e325daa5249411e414bbd995b5e)
1*89a1d03eSRichard// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem %clang_tidy_headers
2*89a1d03eSRichard
3*89a1d03eSRichard#include <stdio.h>
4*89a1d03eSRichard
5*89a1d03eSRichardstatic void TestImplicitFunctionDeclaration(int a) {
6*89a1d03eSRichard  // Call a builtin function so that the compiler generates an implicit
7*89a1d03eSRichard  // function declaration.
8*89a1d03eSRichard  printf("%d", a);
9*89a1d03eSRichard}
10*89a1d03eSRichard
11*89a1d03eSRichardtypedef _Bool bool;
12*89a1d03eSRichard
13*89a1d03eSRichardstatic bool ispositive(int a) { return a > 0; }
14*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: static function named 'ispositive'
15*89a1d03eSRichard// must be in Pascal case as required by Google Objective-C style guide
16*89a1d03eSRichard// CHECK-FIXES: static bool Ispositive(int a) { return a > 0; }
17*89a1d03eSRichard
18*89a1d03eSRichardstatic bool is_positive(int a) { return a > 0; }
19*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: static function named 'is_positive'
20*89a1d03eSRichard// must be in Pascal case as required by Google Objective-C style guide
21*89a1d03eSRichard// CHECK-FIXES: static bool IsPositive(int a) { return a > 0; }
22*89a1d03eSRichard
23*89a1d03eSRichardstatic bool isPositive(int a) { return a > 0; }
24*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: static function named 'isPositive'
25*89a1d03eSRichard// must be in Pascal case as required by Google Objective-C style guide
26*89a1d03eSRichard// CHECK-FIXES: static bool IsPositive(int a) { return a > 0; }
27*89a1d03eSRichard
28*89a1d03eSRichardstatic bool Is_Positive(int a) { return a > 0; }
29*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: static function named 'Is_Positive'
30*89a1d03eSRichard// must be in Pascal case as required by Google Objective-C style guide
31*89a1d03eSRichard// CHECK-FIXES: static bool IsPositive(int a) { return a > 0; }
32*89a1d03eSRichard
33*89a1d03eSRichardstatic bool IsPositive(int a) { return a > 0; }
34*89a1d03eSRichard
35*89a1d03eSRichardbool ispalindrome(const char *str);
36*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function in global namespace named
37*89a1d03eSRichard// 'ispalindrome' must have an appropriate prefix followed by Pascal case as
38*89a1d03eSRichard// required by Google Objective-C style guide
39*89a1d03eSRichard
40*89a1d03eSRichardstatic const char *md5(const char *str) { return 0; }
41*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: static function named 'md5' must be
42*89a1d03eSRichard// in Pascal case as required by Google Objective-C style guide
43*89a1d03eSRichard// CHECK-FIXES: static const char *Md5(const char *str) { return 0; }
44*89a1d03eSRichard
45*89a1d03eSRichardstatic const char *MD5(const char *str) { return 0; }
46*89a1d03eSRichard
47*89a1d03eSRichardstatic const char *URL(void) { return "https://clang.llvm.org/"; }
48*89a1d03eSRichard
49*89a1d03eSRichardstatic const char *DEFURL(void) { return "https://clang.llvm.org/"; }
50*89a1d03eSRichard
51*89a1d03eSRichardstatic const char *DEFFooURL(void) { return "https://clang.llvm.org/"; }
52*89a1d03eSRichard
53*89a1d03eSRichardstatic const char *StringFromNSString(id str) { return ""; }
54*89a1d03eSRichard
55*89a1d03eSRichardvoid ABLog_String(const char *str);
56*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function in global namespace named
57*89a1d03eSRichard// 'ABLog_String' must have an appropriate prefix followed by Pascal case as
58*89a1d03eSRichard// required by Google Objective-C style guide
59*89a1d03eSRichard
60*89a1d03eSRichardvoid ABLogString(const char *str);
61*89a1d03eSRichard
62*89a1d03eSRichardbool IsPrime(int a);
63*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function in global namespace named
64*89a1d03eSRichard// 'IsPrime' must have an appropriate prefix followed by Pascal case as required
65*89a1d03eSRichard// by Google Objective-C style guide
66*89a1d03eSRichard
67*89a1d03eSRichardconst char *ABURL(void) { return "https://clang.llvm.org/"; }
68*89a1d03eSRichard
69*89a1d03eSRichardconst char *ABFooURL(void) { return "https://clang.llvm.org/"; }
70*89a1d03eSRichard
71*89a1d03eSRichardint main(int argc, const char **argv) { return 0; }
72