11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 void CloexecOpenCheck::registerMatchers(MatchFinder *Finder) {
21 auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
22 registerMatchersImpl(Finder,
23 functionDecl(isExternC(), returns(isInteger()),
24 hasAnyName(
"open",
"open64"),
25 hasParameter(0, CharPointerType),
26 hasParameter(1, hasType(isInteger()))));
27 registerMatchersImpl(Finder,
28 functionDecl(isExternC(), returns(isInteger()),
30 hasParameter(0, hasType(isInteger())),
31 hasParameter(1, CharPointerType),
32 hasParameter(2, hasType(isInteger()))));
35 void CloexecOpenCheck::check(
const MatchFinder::MatchResult &Result) {
36 const auto *FD = Result.Nodes.getNodeAs<FunctionDecl>(FuncDeclBindingStr);
37 assert(FD->param_size() > 1);
38 int ArgPos = (FD->param_size() > 2) ? 2 : 1;
39 insertMacroFlag(Result,
"O_CLOEXEC", ArgPos);
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//