1b06b248aSChris Cotter //===--- AvoidReferenceCoroutineParametersCheck.h - clang-tidy --*- C++ -*-===//
2b06b248aSChris Cotter //
3b06b248aSChris Cotter // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4b06b248aSChris Cotter // See https://llvm.org/LICENSE.txt for license information.
5b06b248aSChris Cotter // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6b06b248aSChris Cotter //
7b06b248aSChris Cotter //===----------------------------------------------------------------------===//
8b06b248aSChris Cotter 
9b06b248aSChris Cotter #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDREFERENCECOROUTINEPARAMETERSCHECK_H
10b06b248aSChris Cotter #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDREFERENCECOROUTINEPARAMETERSCHECK_H
11b06b248aSChris Cotter 
12b06b248aSChris Cotter #include "../ClangTidyCheck.h"
13b06b248aSChris Cotter 
14*4718da50SCarlos Galvez namespace clang::tidy::cppcoreguidelines {
15b06b248aSChris Cotter 
16b06b248aSChris Cotter /// Warns on coroutines that accept reference parameters. Accessing a reference
17b06b248aSChris Cotter /// after a coroutine suspension point is not safe since the reference may no
18b06b248aSChris Cotter /// longer be valid. This implements CppCoreGuideline CP.53.
19b06b248aSChris Cotter ///
20b06b248aSChris Cotter /// For the user-facing documentation see:
21b06b248aSChris Cotter /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.html
22b06b248aSChris Cotter class AvoidReferenceCoroutineParametersCheck : public ClangTidyCheck {
23b06b248aSChris Cotter public:
AvoidReferenceCoroutineParametersCheck(StringRef Name,ClangTidyContext * Context)24b06b248aSChris Cotter   AvoidReferenceCoroutineParametersCheck(StringRef Name,
25b06b248aSChris Cotter                                          ClangTidyContext *Context)
26b06b248aSChris Cotter       : ClangTidyCheck(Name, Context) {}
27b06b248aSChris Cotter   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
28b06b248aSChris Cotter   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
isLanguageVersionSupported(const LangOptions & LangOpts)29b06b248aSChris Cotter   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30b06b248aSChris Cotter     return LangOpts.CPlusPlus20;
31b06b248aSChris Cotter   }
32b06b248aSChris Cotter };
33b06b248aSChris Cotter 
34*4718da50SCarlos Galvez } // namespace clang::tidy::cppcoreguidelines
35b06b248aSChris Cotter 
36b06b248aSChris Cotter #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDREFERENCECOROUTINEPARAMETERSCHECK_H
37