clang-tools 6.0.0

CloexecMemfdCreateCheck.cpp
Go to the documentation of this file.
1 //===--- CloexecMemfdCreateCheck.cpp - clang-tidy--------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "CloexecMemfdCreateCheck.h"
11
12 using namespace clang::ast_matchers;
13
14 namespace clang {
15 namespace tidy {
16 namespace android {
17
18 void CloexecMemfdCreateCheck::registerMatchers(MatchFinder *Finder) {
19 auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
20 registerMatchersImpl(
21 Finder, functionDecl(returns(isInteger()), hasName("memfd_create"),
22 hasParameter(0, CharPointerType),
23 hasParameter(1, hasType(isInteger()))));
24 }
25
26 void CloexecMemfdCreateCheck::check(const MatchFinder::MatchResult &Result) {
27 insertMacroFlag(Result, "MFD_CLOEXEC", /*ArgPos=*/1);
28 }
29
30 } // namespace android
31 } // namespace tidy
32 } // namespace clang
clang::ast_matchers
Definition: ClangTidyDiagnosticConsumer.h:27
CloexecMemfdCreateCheck.h
clang
Definition: AndroidTidyModule.cpp:28