28 lines · cpp
1// RUN: %check_clang_tidy %s android-cloexec-pipe %t2 3extern "C" int pipe(int pipefd[2]);4 5void 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 12namespace i {13int pipe(int pipefd[2]);14void noWarningInNamespace() {15 int pipefd[2];16 pipe(pipefd);17}18} // namespace i19 20class C {21public:22 int pipe(int pipefd[2]);23 void noWarningForMemberFunction() {24 int pipefd[2];25 pipe(pipefd);26 }27};28