clang-tools  7.0.0
CloexecEpollCreateCheck.cpp
Go to the documentation of this file.
1 //===--- CloexecEpollCreateCheck.cpp - 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 
11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
13 
14 using namespace clang::ast_matchers;
15 
16 namespace clang {
17 namespace tidy {
18 namespace android {
19 
20 void CloexecEpollCreateCheck::registerMatchers(MatchFinder *Finder) {
21  registerMatchersImpl(
22  Finder, functionDecl(returns(isInteger()), hasName("epoll_create"),
23  hasParameter(0, hasType(isInteger()))));
24 }
25 
26 void CloexecEpollCreateCheck::check(const MatchFinder::MatchResult &Result) {
27  replaceFunc(Result,
28  "prefer epoll_create() to epoll_create1() "
29  "because epoll_create1() allows "
30  "EPOLL_CLOEXEC",
31  "epoll_create1(EPOLL_CLOEXEC)");
32 }
33 
34 } // namespace android
35 } // namespace tidy
36 } // namespace clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//