clang-tools
22.0.0git
llvm-project
clang-tools-extra
clang-tidy
darwin
AvoidSpinlockCheck.cpp
Go to the documentation of this file.
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-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
AvoidSpinlockCheck.h
"
10
#include "clang/ASTMatchers/ASTMatchFinder.h"
11
12
using namespace
clang::ast_matchers
;
13
14
namespace
clang::tidy::darwin
{
15
16
void
AvoidSpinlockCheck::registerMatchers
(MatchFinder *Finder) {
17
Finder->addMatcher(
18
callExpr(callee((functionDecl(hasAnyName(
19
"OSSpinlockLock"
,
"OSSpinlockUnlock"
,
"OSSpinlockTry"
)))))
20
.bind(
"spinlock"
),
21
this
);
22
}
23
24
void
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::darwin
AvoidSpinlockCheck.h
clang::tidy::darwin::AvoidSpinlockCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
Definition
AvoidSpinlockCheck.cpp:24
clang::tidy::darwin::AvoidSpinlockCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Definition
AvoidSpinlockCheck.cpp:16
clang::ast_matchers
Definition
AbseilMatcher.h:13
clang::tidy::darwin
Definition
AvoidSpinlockCheck.cpp:14
Generated on
for clang-tools by
1.14.0