Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:20

0001 //===--- CoroutineHostileRAIICheck.h - clang-tidy ----------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINESHOSTILERAIICHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINESHOSTILERAIICHECK_H
0011 
0012 #include "../ClangTidyCheck.h"
0013 #include "clang/AST/ASTTypeTraits.h"
0014 #include "clang/ASTMatchers/ASTMatchFinder.h"
0015 #include "llvm/ADT/StringRef.h"
0016 #include <vector>
0017 
0018 namespace clang::tidy::misc {
0019 
0020 /// Detects when objects of certain hostile RAII types persists across
0021 /// suspension points in a coroutine. Such hostile types include scoped-lockable
0022 /// types and types belonging to a configurable denylist.
0023 ///
0024 ///  For the user-facing documentation see:
0025 ///  http://clang.llvm.org/extra/clang-tidy/checks/misc/coroutine-hostile-raii.html
0026 class CoroutineHostileRAIICheck : public ClangTidyCheck {
0027 public:
0028   CoroutineHostileRAIICheck(llvm::StringRef Name, ClangTidyContext *Context);
0029 
0030   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
0031     return LangOpts.CPlusPlus20;
0032   }
0033 
0034   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0035   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0036   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0037 
0038   std::optional<TraversalKind> getCheckTraversalKind() const override {
0039     return TK_AsIs;
0040   }
0041 
0042 private:
0043   // List of fully qualified types which should not persist across a suspension
0044   // point in a coroutine.
0045   std::vector<StringRef> RAIITypesList;
0046   // List of fully qualified awaitable types which are considered safe to
0047   // co_await.
0048   std::vector<StringRef> AllowedAwaitablesList;
0049 };
0050 
0051 } // namespace clang::tidy::misc
0052 
0053 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINESHOSTILERAIICHECK_H