xref: /llvm-project/clang-tools-extra/clang-tidy/android/CloexecPipe2Check.cpp (revision 7d2ea6c422d3f5712b7253407005e1a465a76946)
13da331b4SGeorge Burgess IV //===--- CloexecPipe2Check.cpp - clang-tidy--------------------------------===//
23da331b4SGeorge Burgess IV //
33da331b4SGeorge Burgess IV // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
43da331b4SGeorge Burgess IV // See https://llvm.org/LICENSE.txt for license information.
53da331b4SGeorge Burgess IV // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
63da331b4SGeorge Burgess IV //
73da331b4SGeorge Burgess IV //===----------------------------------------------------------------------===//
83da331b4SGeorge Burgess IV 
93da331b4SGeorge Burgess IV #include "CloexecPipe2Check.h"
103da331b4SGeorge Burgess IV #include "../utils/ASTUtils.h"
113da331b4SGeorge Burgess IV #include "clang/AST/ASTContext.h"
123da331b4SGeorge Burgess IV #include "clang/ASTMatchers/ASTMatchFinder.h"
133da331b4SGeorge Burgess IV 
143da331b4SGeorge Burgess IV using namespace clang::ast_matchers;
153da331b4SGeorge Burgess IV 
16*7d2ea6c4SCarlos Galvez namespace clang::tidy::android {
173da331b4SGeorge Burgess IV 
registerMatchers(MatchFinder * Finder)183da331b4SGeorge Burgess IV void CloexecPipe2Check::registerMatchers(MatchFinder *Finder) {
193da331b4SGeorge Burgess IV   registerMatchersImpl(Finder,
203da331b4SGeorge Burgess IV                        functionDecl(returns(isInteger()), hasName("pipe2"),
213da331b4SGeorge Burgess IV                                     hasParameter(0, hasType(pointsTo(isInteger()))),
223da331b4SGeorge Burgess IV                                     hasParameter(1, hasType(isInteger()))));
233da331b4SGeorge Burgess IV }
243da331b4SGeorge Burgess IV 
check(const MatchFinder::MatchResult & Result)253da331b4SGeorge Burgess IV void CloexecPipe2Check::check(const MatchFinder::MatchResult &Result) {
263da331b4SGeorge Burgess IV   insertMacroFlag(Result, /*MacroFlag=*/"O_CLOEXEC", /*ArgPos=*/1);
273da331b4SGeorge Burgess IV }
283da331b4SGeorge Burgess IV 
29*7d2ea6c4SCarlos Galvez } // namespace clang::tidy::android
30