clang-tools  8.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.
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
Finds code that opens file without using the O_CLOEXEC flag.
This file contains the declaration of the CloexecCheck class, which is the base class for all of the ...
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
static constexpr llvm::StringLiteral Name
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
The base class for all close-on-exec checks in Android module.
Definition: CloexecCheck.h:29
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
CloexecOpenCheck(StringRef Name, ClangTidyContext *Context)