blob: 7165d24f53f0e2b96a33bcdb472cb9a70e6dddea [file] [log] [blame]
Chih-Hung Hsieh41d29b12017-08-16 18:02:49 +00001//===--- 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
10#include "CloexecEpollCreateCheck.h"
11#include "clang/AST/ASTContext.h"
12#include "clang/ASTMatchers/ASTMatchFinder.h"
13
14using namespace clang::ast_matchers;
15
16namespace clang {
17namespace tidy {
18namespace android {
19
20void CloexecEpollCreateCheck::registerMatchers(MatchFinder *Finder) {
21 registerMatchersImpl(
22 Finder, functionDecl(returns(isInteger()), hasName("epoll_create"),
23 hasParameter(0, hasType(isInteger()))));
24}
25
26void 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