clang-tools 22.0.0git
clang::tidy::android::CloexecOpenCheck Class Reference

Finds code that opens file without using the O_CLOEXEC flag. More...

#include <CloexecOpenCheck.h>

Inheritance diagram for clang::tidy::android::CloexecOpenCheck:
[legend]

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ CloexecOpenCheck()

clang::tidy::android::CloexecOpenCheck::CloexecOpenCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Member Function Documentation

◆ check()

void clang::tidy::android::CloexecOpenCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

◆ registerMatchers()

void clang::tidy::android::CloexecOpenCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

The documentation for this class was generated from the following files: