11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
21 auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
22 auto MODETType = hasType(namedDecl(hasName(
"mode_t")));
23 registerMatchersImpl(Finder,
24 functionDecl(isExternC(), returns(isInteger()),
26 hasParameter(0, CharPointerType),
27 hasParameter(1, MODETType)));
30 void CloexecCreatCheck::check(
const MatchFinder::MatchResult &Result) {
31 const std::string &ReplacementText =
32 (Twine(
"open (") + getSpellingArg(Result, 0) +
33 ", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, " +
34 getSpellingArg(Result, 1) +
")")
37 "prefer open() to creat() because open() allows O_CLOEXEC",
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//