1// RUN: %check_clang_tidy %s android-cloexec-dup %t
2
3extern "C" int dup(int oldfd);
4void f() {
5 dup(oldfd: 1);
6 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer fcntl() to dup() because fcntl() allows F_DUPFD_CLOEXEC [android-cloexec-dup]
7 // CHECK-FIXES: fcntl(1, F_DUPFD_CLOEXEC);
8 int oldfd = 0;
9 dup(oldfd);
10 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer
11 // CHECK-FIXES: fcntl(oldfd, F_DUPFD_CLOEXEC);
12}
13
14namespace i {
15int dup(int oldfd);
16void g() {
17 dup(oldfd: 0);
18 int oldfd = 1;
19 dup(oldfd);
20}
21} // namespace i
22
23class C {
24public:
25 int dup(int oldfd);
26 void h() {
27 dup(oldfd: 0);
28 int oldfd = 1;
29 dup(oldfd);
30 }
31};
32

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