1// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
2// RUN: -config='{CheckOptions: { \
3// RUN: readability-identifier-naming.ParameterCase: CamelCase, \
4// RUN: readability-identifier-naming.IgnoreMainLikeFunctions: true \
5// RUN: }}'
6
7int mainLike(int argc, char **argv);
8int mainLike(int argc, char **argv, const char **env);
9int mainLike(int argc, const char **argv);
10int mainLike(int argc, const char **argv, const char **env);
11int mainLike(int argc, char *argv[]);
12int mainLike(int argc, const char *argv[]);
13int mainLike(int argc, char *argv[], char *env[]);
14int mainLike(int argc, const char *argv[], const char *env[]);
15void notMain(int argc, char **argv);
16// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'argc'
17// CHECK-MESSAGES: :[[@LINE-2]]:31: warning: invalid case style for parameter 'argv'
18void notMain(int argc, char **argv, char **env);
19// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'argc'
20// CHECK-MESSAGES: :[[@LINE-2]]:31: warning: invalid case style for parameter 'argv'
21// CHECK-MESSAGES: :[[@LINE-3]]:44: warning: invalid case style for parameter 'env'
22int notMain(int argc, char **argv, char **env, int Extra);
23// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
24// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'argv'
25// CHECK-MESSAGES: :[[@LINE-3]]:43: warning: invalid case style for parameter 'env'
26int notMain(int argc, char **argv, int Extra);
27// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
28// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'argv'
29int notMain(int argc, char *argv);
30// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
31// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: invalid case style for parameter 'argv'
32int notMain(unsigned argc, char **argv);
33// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for parameter 'argc'
34// CHECK-MESSAGES: :[[@LINE-2]]:35: warning: invalid case style for parameter 'argv'
35int notMain(long argc, char *argv);
36// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'argc'
37// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'argv'
38int notMain(int argc, char16_t **argv);
39// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
40// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: invalid case style for parameter 'argv'
41int notMain(int argc, char argv[]);
42// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
43// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: invalid case style for parameter 'argv'
44typedef char myFunChar;
45typedef int myFunInt;
46typedef char **myFunCharPtr;
47typedef long myFunLong;
48myFunInt mainLikeTypedef(myFunInt argc, myFunChar **argv);
49int mainLikeTypedef(int argc, myFunCharPtr argv);
50int notMainTypedef(myFunLong argc, char **argv);
51// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: invalid case style for parameter 'argc'
52// CHECK-MESSAGES: :[[@LINE-2]]:43: warning: invalid case style for parameter 'argv'
53
54// Don't flag as name contains the word main
55int myMainFunction(int argc, char *argv[]);
56
57// This is fine, named with wmain and has wchar ptr.
58int wmainLike(int argc, wchar_t *argv[]);
59
60// Flag this as has signature of main, but named as wmain.
61int wmainLike(int argc, char *argv[]);
62// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for parameter 'argc'
63// CHECK-MESSAGES: :[[@LINE-2]]:31: warning: invalid case style for parameter 'argv'
64
65struct Foo {
66 Foo(int argc, char *argv[]) {}
67 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for parameter 'argc'
68 // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: invalid case style for parameter 'argv'
69
70 int mainPub(int argc, char *argv[]);
71 static int mainPubStatic(int argc, char *argv[]);
72
73protected:
74 int mainProt(int argc, char *argv[]);
75 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for parameter 'argc'
76 // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: invalid case style for parameter 'argv'
77 static int mainProtStatic(int argc, char *argv[]);
78 // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: invalid case style for parameter 'argc'
79 // CHECK-MESSAGES: :[[@LINE-2]]:45: warning: invalid case style for parameter 'argv'
80
81private:
82 int mainPriv(int argc, char *argv[]);
83 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for parameter 'argc'
84 // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: invalid case style for parameter 'argv'
85 static int mainPrivStatic(int argc, char *argv[]);
86 // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: invalid case style for parameter 'argc'
87 // CHECK-MESSAGES: :[[@LINE-2]]:45: warning: invalid case style for parameter 'argv'
88};
89

source code of clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-main-like.cpp