1// RUN: %check_clang_tidy %s android-cloexec-accept %t
2
3struct sockaddr {};
4typedef int socklen_t;
5#define NULL 0
6
7extern "C" int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
8
9void f() {
10 accept(sockfd: 0, NULL, NULL);
11 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC [android-cloexec-accept]
12 // CHECK-FIXES: accept4(0, NULL, NULL, SOCK_CLOEXEC);
13}
14
15namespace i {
16int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
17void g() {
18 accept(sockfd: 0, NULL, NULL);
19}
20} // namespace i
21
22class C {
23public:
24 int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
25 void h() {
26 accept(sockfd: 0, NULL, NULL);
27 }
28};
29

source code of clang-tools-extra/test/clang-tidy/checkers/android/cloexec-accept.cpp