CloexecPipe2Check.cpp 1.1 KB

1234567891011121314151617181920212223242526272829
  1. //===--- CloexecPipe2Check.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 "CloexecPipe2Check.h"
  9. #include "../utils/ASTUtils.h"
  10. #include "clang/AST/ASTContext.h"
  11. #include "clang/ASTMatchers/ASTMatchFinder.h"
  12. using namespace clang::ast_matchers;
  13. namespace clang::tidy::android {
  14. void CloexecPipe2Check::registerMatchers(MatchFinder *Finder) {
  15. registerMatchersImpl(Finder,
  16. functionDecl(returns(isInteger()), hasName("pipe2"),
  17. hasParameter(0, hasType(pointsTo(isInteger()))),
  18. hasParameter(1, hasType(isInteger()))));
  19. }
  20. void CloexecPipe2Check::check(const MatchFinder::MatchResult &Result) {
  21. insertMacroFlag(Result, /*MacroFlag=*/"O_CLOEXEC", /*ArgPos=*/1);
  22. }
  23. } // namespace clang::tidy::android