[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang-tools-extra / clang-tidy / android / CloexecAccept4Check.cpp
blob77dca9be895800612fd09a3e735767160477433a
1 //===--- CloexecAccept4Check.cpp - clang-tidy------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "CloexecAccept4Check.h"
10 #include "../utils/ASTUtils.h"
11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
14 using namespace clang::ast_matchers;
16 namespace clang::tidy::android {
18 void CloexecAccept4Check::registerMatchers(MatchFinder *Finder) {
19 auto SockAddrPointerType =
20 hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr"))));
21 auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t"))));
23 registerMatchersImpl(Finder,
24 functionDecl(returns(isInteger()), hasName("accept4"),
25 hasParameter(0, hasType(isInteger())),
26 hasParameter(1, SockAddrPointerType),
27 hasParameter(2, SockLenPointerType),
28 hasParameter(3, hasType(isInteger()))));
31 void CloexecAccept4Check::check(const MatchFinder::MatchResult &Result) {
32 insertMacroFlag(Result, /*MacroFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/3);
35 } // namespace clang::tidy::android