1 | // RUN: %check_clang_tidy %s android-cloexec-dup %t |
2 | |
3 | extern "C" int dup(int oldfd); |
4 | void 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 | |
14 | namespace i { |
15 | int dup(int oldfd); |
16 | void g() { |
17 | dup(oldfd: 0); |
18 | int oldfd = 1; |
19 | dup(oldfd); |
20 | } |
21 | } // namespace i |
22 | |
23 | class C { |
24 | public: |
25 | int dup(int oldfd); |
26 | void h() { |
27 | dup(oldfd: 0); |
28 | int oldfd = 1; |
29 | dup(oldfd); |
30 | } |
31 | }; |
32 | |