Changeset View
Changeset View
Standalone View
Standalone View
clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
- This file was added.
// RUN: %check_clang_tidy %s android-cloexec-pipe %t | |||||
extern "C" int pipe(int pipefd[2]); | |||||
void warning() { | |||||
int pipefd[2]; | |||||
gribozavr: Please give the tests informative names instead of `f`, `g` etc. | |||||
pipe(pipefd); | |||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes [android-cloexec-pipe] | |||||
// CHECK-FIXES: pipe2(pipefd, O_CLOEXEC); | |||||
} | |||||
Not Done ReplyInline Actions(Do we have a CHECK-FIXES-NOT or CHECK-MESSAGES-NOT to apply to the things below? Or are the CHECKs here meant to be complete like clang's -verify?) george.burgess.iv: (Do we have a CHECK-FIXES-NOT or CHECK-MESSAGES-NOT to apply to the things below? Or are the… | |||||
Based on Testing Checks https://clang.llvm.org/extra/clang-tidy/Contributing.html, CHECK-MASSAGES and CHECK-FIXES are sufficient for clang-tidy checks. I have double checked the tests for similar checks and they don't seem to have additional FileCheck invocations other than these two. jcai19: Based on Testing Checks https://clang.llvm.org/extra/clang-tidy/Contributing.html, CHECK… | |||||
namespace i { | |||||
int pipe(int pipefd[2]); | |||||
void noWarningInNamespace() { | |||||
int pipefd[2]; | |||||
noWarningForPipeInNamespace ? gribozavr: noWarningForPipeInNamespace ? | |||||
pipe(pipefd); | |||||
} | |||||
} // namespace i | |||||
nit: no need to do it explicitly, if a warning is shown unexpectedly, the test will fail. hokein: nit: no need to do it explicitly, if a warning is shown unexpectedly, the test will fail. | |||||
Not Done ReplyInline ActionsI somehow never realized this (and there seem to be several places that also don't realize it). Thanks for letting us know. srhines: I somehow never realized this (and there seem to be several places that also don't realize it). | |||||
Thanks for the clarification. jcai19: Thanks for the clarification. | |||||
class C { | |||||
public: | |||||
int pipe(int pipefd[2]); | |||||
void noWarningForMemberFunction() { | |||||
int pipefd[2]; | |||||
noWarningForPipeMemberFunction ? gribozavr: noWarningForPipeMemberFunction ? | |||||
pipe(pipefd); | |||||
} | |||||
}; |
Please give the tests informative names instead of f, g etc.