clang-tools 22.0.0git
|
Finds code that opens file without using the O_CLOEXEC flag. More...
#include <CloexecOpenCheck.h>
Public Member Functions | |
CloexecOpenCheck (StringRef Name, ClangTidyContext *Context) | |
void | registerMatchers (ast_matchers::MatchFinder *Finder) override |
void | check (const ast_matchers::MatchFinder::MatchResult &Result) override |
Public Member Functions inherited from clang::tidy::android::CloexecCheck | |
CloexecCheck (StringRef Name, ClangTidyContext *Context) |
Additional Inherited Members | |
Protected Member Functions inherited from clang::tidy::android::CloexecCheck | |
void | registerMatchersImpl (ast_matchers::MatchFinder *Finder, ast_matchers::internal::Matcher< FunctionDecl > Function) |
void | insertMacroFlag (const ast_matchers::MatchFinder::MatchResult &Result, StringRef MacroFlag, int ArgPos) |
Currently, we have three types of fixes. | |
void | replaceFunc (const ast_matchers::MatchFinder::MatchResult &Result, StringRef WarningMsg, StringRef FixMsg) |
Type2 is to replace the API to another function that has required the ability. | |
void | insertStringFlag (const ast_matchers::MatchFinder::MatchResult &Result, const char Mode, const int ArgPos) |
Type3 is also to add a flag to the corresponding argument, but this time, the flag is some string and each char represents a mode rather than a macro. | |
StringRef | getSpellingArg (const ast_matchers::MatchFinder::MatchResult &Result, int N) const |
Helper function to get the spelling of a particular argument. | |
Static Protected Attributes inherited from clang::tidy::android::CloexecCheck | |
static const char * | FuncDeclBindingStr = "funcDecl" |
Binding name of the FuncDecl of a function call. | |
static const char * | FuncBindingStr = "func" |
Binding name of the function call expression. |
Finds code that opens file without using the O_CLOEXEC flag.
open(), openat(), and open64() had better to include O_CLOEXEC in their flags argument. Only consider simple cases that the corresponding argument is constant or binary operation OR among constants like 'O_CLOEXEC' or 'O_CLOEXEC | O_RDONLY'. No constant propagation is performed.
Only the symbolic 'O_CLOEXEC' macro definition is checked, not the concrete value.
Definition at line 25 of file CloexecOpenCheck.h.
|
inline |
Definition at line 27 of file CloexecOpenCheck.h.
References clang::tidy::android::CloexecCheck::CloexecCheck().
|
override |
Definition at line 30 of file CloexecOpenCheck.cpp.
References clang::tidy::android::CloexecCheck::FuncDeclBindingStr, and clang::tidy::android::CloexecCheck::insertMacroFlag().
|
override |
Definition at line 16 of file CloexecOpenCheck.cpp.
References clang::tidy::android::CloexecCheck::registerMatchersImpl().