1 // RUN: %check_clang_tidy %s android-cloexec-pipe %t
2 
3 extern "C" int pipe(int pipefd[2]);
4 
warning()5 void warning() {
6   int pipefd[2];
7   pipe(pipefd);
8   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes [android-cloexec-pipe]
9   // CHECK-FIXES: pipe2(pipefd, O_CLOEXEC);
10 }
11 
12 namespace i {
13 int pipe(int pipefd[2]);
noWarningInNamespace()14 void noWarningInNamespace() {
15   int pipefd[2];
16   pipe(pipefd);
17 }
18 } // namespace i
19 
20 class C {
21 public:
22   int pipe(int pipefd[2]);
noWarningForMemberFunction()23   void noWarningForMemberFunction() {
24     int pipefd[2];
25     pipe(pipefd);
26   }
27 };
28