clang-tools
20.0.0git
llvm-project
clang-tools-extra
clang-tidy
misc
CoroutineHostileRAIICheck.h
Go to the documentation of this file.
1
//===--- CoroutineHostileRAIICheck.h - clang-tidy ----------------*- C++-*-===//
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
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINESHOSTILERAIICHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINESHOSTILERAIICHECK_H
11
12
#include "../ClangTidyCheck.h"
13
#include "clang/AST/ASTTypeTraits.h"
14
#include "clang/ASTMatchers/ASTMatchFinder.h"
15
#include "llvm/ADT/StringRef.h"
16
#include <vector>
17
18
namespace
clang::tidy::misc
{
19
20
/// Detects when objects of certain hostile RAII types persists across
21
/// suspension points in a coroutine. Such hostile types include scoped-lockable
22
/// types and types belonging to a configurable denylist.
23
///
24
/// For the user-facing documentation see:
25
/// http://clang.llvm.org/extra/clang-tidy/checks/misc/coroutine-hostile-raii.html
26
class
CoroutineHostileRAIICheck
:
public
ClangTidyCheck
{
27
public
:
28
CoroutineHostileRAIICheck
(llvm::StringRef
Name
,
ClangTidyContext
*Context);
29
30
bool
isLanguageVersionSupported
(
const
LangOptions &LangOpts)
const override
{
31
return
LangOpts.CPlusPlus20;
32
}
33
34
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
35
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
36
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
37
38
std::optional<TraversalKind>
getCheckTraversalKind
()
const override
{
39
return
TK_AsIs;
40
}
41
42
private
:
43
// List of fully qualified types which should not persist across a suspension
44
// point in a coroutine.
45
std::vector<StringRef> RAIITypesList;
46
// List of fully qualified awaitable types which are considered safe to
47
// co_await.
48
std::vector<StringRef> AllowedAwaitablesList;
49
};
50
51
}
// namespace clang::tidy::misc
52
53
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINESHOSTILERAIICHECK_H
Name
llvm::SmallString< 256U > Name
Definition:
ChainedComparisonCheck.cpp:42
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:53
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::misc::CoroutineHostileRAIICheck
Detects when objects of certain hostile RAII types persists across suspension points in a coroutine.
Definition:
CoroutineHostileRAIICheck.h:26
clang::tidy::misc::CoroutineHostileRAIICheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
CoroutineHostileRAIICheck.cpp:93
clang::tidy::misc::CoroutineHostileRAIICheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition:
CoroutineHostileRAIICheck.cpp:108
clang::tidy::misc::CoroutineHostileRAIICheck::isLanguageVersionSupported
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
Definition:
CoroutineHostileRAIICheck.h:30
clang::tidy::misc::CoroutineHostileRAIICheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
CoroutineHostileRAIICheck.cpp:78
clang::tidy::misc::CoroutineHostileRAIICheck::getCheckTraversalKind
std::optional< TraversalKind > getCheckTraversalKind() const override
Definition:
CoroutineHostileRAIICheck.h:38
clang::tidy::misc
Definition:
ConfusableIdentifierCheck.cpp:25
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:126
Generated on Sat Dec 21 2024 14:58:59 for clang-tools by
1.9.6