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