154178fc6SNoah Watkins //===--- AvoidCapturingLambdaCoroutinesCheck.h - clang-tidy -----*- C++ -*-===// 254178fc6SNoah Watkins // 354178fc6SNoah Watkins // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 454178fc6SNoah Watkins // See https://llvm.org/LICENSE.txt for license information. 554178fc6SNoah Watkins // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 654178fc6SNoah Watkins // 754178fc6SNoah Watkins //===----------------------------------------------------------------------===// 854178fc6SNoah Watkins 954178fc6SNoah Watkins #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDCAPTURINGLAMBDACOROUTINESCHECK_H 1054178fc6SNoah Watkins #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDCAPTURINGLAMBDACOROUTINESCHECK_H 1154178fc6SNoah Watkins 1254178fc6SNoah Watkins #include "../ClangTidyCheck.h" 1354178fc6SNoah Watkins 14*17d403f6SPiotr Zegar namespace clang::tidy::cppcoreguidelines { 1554178fc6SNoah Watkins 16*17d403f6SPiotr Zegar /// Flags C++20 coroutine lambdas with non-empty capture lists that may cause 17*17d403f6SPiotr Zegar /// use-after-free errors and suggests avoiding captures or ensuring the lambda 18*17d403f6SPiotr Zegar /// closure object has a guaranteed lifetime. 1954178fc6SNoah Watkins /// 2054178fc6SNoah Watkins /// For the user-facing documentation see: 21*17d403f6SPiotr Zegar /// https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-capturing-lambda-coroutines.html 2254178fc6SNoah Watkins class AvoidCapturingLambdaCoroutinesCheck : public ClangTidyCheck { 2354178fc6SNoah Watkins public: AvoidCapturingLambdaCoroutinesCheck(StringRef Name,ClangTidyContext * Context)2454178fc6SNoah Watkins AvoidCapturingLambdaCoroutinesCheck(StringRef Name, ClangTidyContext *Context) 2554178fc6SNoah Watkins : ClangTidyCheck(Name, Context) {} 2654178fc6SNoah Watkins void registerMatchers(ast_matchers::MatchFinder *Finder) override; 2754178fc6SNoah Watkins void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 28*17d403f6SPiotr Zegar bool isLanguageVersionSupported(const LangOptions &LangOpts) const override; 2954178fc6SNoah Watkins }; 3054178fc6SNoah Watkins 31*17d403f6SPiotr Zegar } // namespace clang::tidy::cppcoreguidelines 3254178fc6SNoah Watkins 3354178fc6SNoah Watkins #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDCAPTURINGLAMBDACOROUTINESCHECK_H 34