clang-tools 6.0.0

CloexecOpenCheck.h
Go to the documentation of this file.
1 //===--- CloexecOpenCheck.h - clang-tidy-----------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_OPEN_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_OPEN_H
12
13 #include "CloexecCheck.h"
14
15 namespace clang {
16 namespace tidy {
17 namespace android {
18
19 /// Finds code that opens file without using the O_CLOEXEC flag.
20 ///
21 /// open(), openat(), and open64() had better to include O_CLOEXEC in their
22 /// flags argument. Only consider simple cases that the corresponding argument
23 /// is constant or binary operation OR among constants like 'O_CLOEXEC' or
24 /// 'O_CLOEXEC | O_RDONLY'. No constant propagation is performed.
25 ///
26 /// Only the symbolic 'O_CLOEXEC' macro definition is checked, not the concrete
27 /// value.
28 class CloexecOpenCheck : public CloexecCheck {
29 public:
30 CloexecOpenCheck(StringRef Name, ClangTidyContext *Context)
31 : CloexecCheck(Name, Context) {}
32 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
33 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
34 };
35
36 } // namespace android
37 } // namespace tidy
38 } // namespace clang
39
40 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_OPEN_H
clang::tidy::android::CloexecOpenCheck
Finds code that opens file without using the O_CLOEXEC flag.
Definition: CloexecOpenCheck.h:28
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
CloexecCheck.h
This file contains the declaration of the CloexecCheck class, which is the base class for all of the ...
clang::tidy::android::CloexecOpenCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: CloexecOpenCheck.cpp:20
clang::tidy::android::CloexecOpenCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: CloexecOpenCheck.cpp:35
clang::tidy::android::CloexecCheck
The base class for all close-on-exec checks in Android module.
Definition: CloexecCheck.h:29
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
clang::tidy::android::CloexecOpenCheck::CloexecOpenCheck
CloexecOpenCheck(StringRef Name, ClangTidyContext *Context)
Definition: CloexecOpenCheck.h:30