brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 8cf22ba Raw
34 lines · cpp
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "CloexecAccept4Check.h"10#include "clang/ASTMatchers/ASTMatchFinder.h"11 12using namespace clang::ast_matchers;13 14namespace clang::tidy::android {15 16void CloexecAccept4Check::registerMatchers(MatchFinder *Finder) {17  auto SockAddrPointerType =18      hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr"))));19  auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t"))));20 21  registerMatchersImpl(Finder,22                       functionDecl(returns(isInteger()), hasName("accept4"),23                                    hasParameter(0, hasType(isInteger())),24                                    hasParameter(1, SockAddrPointerType),25                                    hasParameter(2, SockLenPointerType),26                                    hasParameter(3, hasType(isInteger()))));27}28 29void CloexecAccept4Check::check(const MatchFinder::MatchResult &Result) {30  insertMacroFlag(Result, /*MacroFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/3);31}32 33} // namespace clang::tidy::android34