[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang-tools-extra / clang-tidy / android / CloexecFopenCheck.cpp
blobab165981236ee548b5ca102b6f841d7604605f6b
1 //===--- CloexecFopenCheck.cpp - clang-tidy--------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "CloexecFopenCheck.h"
10 #include "clang/AST/ASTContext.h"
11 #include "clang/AST/Type.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
13 #include "clang/Lex/Lexer.h"
15 using namespace clang::ast_matchers;
17 namespace clang::tidy::android {
19 void CloexecFopenCheck::registerMatchers(MatchFinder *Finder) {
20 auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
21 registerMatchersImpl(Finder,
22 functionDecl(isExternC(), returns(asString("FILE *")),
23 hasName("fopen"),
24 hasParameter(0, CharPointerType),
25 hasParameter(1, CharPointerType)));
28 void CloexecFopenCheck::check(const MatchFinder::MatchResult &Result) {
29 insertStringFlag(Result, /*Mode=*/'e', /*ArgPos=*/1);
32 } // namespace clang::tidy::android