brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 875a851 Raw
32 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 "AvoidSpinlockCheck.h"10#include "clang/ASTMatchers/ASTMatchFinder.h"11 12using namespace clang::ast_matchers;13 14namespace clang::tidy::darwin {15 16void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) {17  Finder->addMatcher(18      callExpr(callee((functionDecl(hasAnyName(19                   "OSSpinlockLock", "OSSpinlockUnlock", "OSSpinlockTry")))))20          .bind("spinlock"),21      this);22}23 24void AvoidSpinlockCheck::check(const MatchFinder::MatchResult &Result) {25  const auto *MatchedExpr = Result.Nodes.getNodeAs<CallExpr>("spinlock");26  diag(MatchedExpr->getBeginLoc(),27       "use os_unfair_lock_lock() or dispatch queue APIs instead of the "28       "deprecated OSSpinLock");29}30 31} // namespace clang::tidy::darwin32