11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 void CloexecAcceptCheck::registerMatchers(MatchFinder *Finder) {
21 auto SockAddrPointerType =
22 hasType(pointsTo(recordDecl(isStruct(), hasName(
"sockaddr"))));
23 auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName(
"socklen_t"))));
25 registerMatchersImpl(Finder,
26 functionDecl(returns(isInteger()), hasName(
"accept"),
27 hasParameter(0, hasType(isInteger())),
28 hasParameter(1, SockAddrPointerType),
29 hasParameter(2, SockLenPointerType)));
32 void CloexecAcceptCheck::check(
const MatchFinder::MatchResult &Result) {
33 const std::string &ReplacementText =
34 (Twine(
"accept4(") + getSpellingArg(Result, 0) +
", " +
35 getSpellingArg(Result, 1) +
", " + getSpellingArg(Result, 2) +
41 "prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC",
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//