xref: /llvm-project/clang-tools-extra/clang-tidy/android/CloexecInotifyInit1Check.cpp (revision 7d2ea6c422d3f5712b7253407005e1a465a76946)
17651e66cSChih-Hung Hsieh //===--- CloexecInotifyInit1Check.cpp - clang-tidy-------------------------===//
27651e66cSChih-Hung Hsieh //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67651e66cSChih-Hung Hsieh //
77651e66cSChih-Hung Hsieh //===----------------------------------------------------------------------===//
87651e66cSChih-Hung Hsieh 
97651e66cSChih-Hung Hsieh #include "CloexecInotifyInit1Check.h"
107651e66cSChih-Hung Hsieh #include "../utils/ASTUtils.h"
117651e66cSChih-Hung Hsieh #include "clang/AST/ASTContext.h"
127651e66cSChih-Hung Hsieh #include "clang/ASTMatchers/ASTMatchFinder.h"
137651e66cSChih-Hung Hsieh 
147651e66cSChih-Hung Hsieh using namespace clang::ast_matchers;
157651e66cSChih-Hung Hsieh 
16*7d2ea6c4SCarlos Galvez namespace clang::tidy::android {
177651e66cSChih-Hung Hsieh 
registerMatchers(MatchFinder * Finder)187651e66cSChih-Hung Hsieh void CloexecInotifyInit1Check::registerMatchers(MatchFinder *Finder) {
197651e66cSChih-Hung Hsieh   registerMatchersImpl(
207651e66cSChih-Hung Hsieh       Finder, functionDecl(returns(isInteger()), hasName("inotify_init1"),
217651e66cSChih-Hung Hsieh                            hasParameter(0, hasType(isInteger()))));
227651e66cSChih-Hung Hsieh }
237651e66cSChih-Hung Hsieh 
check(const MatchFinder::MatchResult & Result)247651e66cSChih-Hung Hsieh void CloexecInotifyInit1Check::check(const MatchFinder::MatchResult &Result) {
2526f2eec2SBenjamin Kramer   insertMacroFlag(Result, /*MacroFlag=*/"IN_CLOEXEC", /*ArgPos=*/0);
267651e66cSChih-Hung Hsieh }
277651e66cSChih-Hung Hsieh 
28*7d2ea6c4SCarlos Galvez } // namespace clang::tidy::android
29