29 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 "CloexecFopenCheck.h"10#include "clang/ASTMatchers/ASTMatchFinder.h"11 12using namespace clang::ast_matchers;13 14namespace clang::tidy::android {15 16void CloexecFopenCheck::registerMatchers(MatchFinder *Finder) {17 auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));18 registerMatchersImpl(19 Finder, functionDecl(isExternC(), returns(asString("FILE *")),20 hasName("fopen"), hasParameter(0, CharPointerType),21 hasParameter(1, CharPointerType)));22}23 24void CloexecFopenCheck::check(const MatchFinder::MatchResult &Result) {25 insertStringFlag(Result, /*Mode=*/'e', /*ArgPos=*/1);26}27 28} // namespace clang::tidy::android29