CloexecMemfdCreateCheck.cpp 1.0 KB

123456789101112131415161718192021222324252627
  1. //===--- CloexecMemfdCreateCheck.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. //===----------------------------------------------------------------------===//
  8. #include "CloexecMemfdCreateCheck.h"
  9. using namespace clang::ast_matchers;
  10. namespace clang::tidy::android {
  11. void CloexecMemfdCreateCheck::registerMatchers(MatchFinder *Finder) {
  12. auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
  13. registerMatchersImpl(
  14. Finder, functionDecl(returns(isInteger()), hasName("memfd_create"),
  15. hasParameter(0, CharPointerType),
  16. hasParameter(1, hasType(isInteger()))));
  17. }
  18. void CloexecMemfdCreateCheck::check(const MatchFinder::MatchResult &Result) {
  19. insertMacroFlag(Result, "MFD_CLOEXEC", /*ArgPos=*/1);
  20. }
  21. } // namespace clang::tidy::android