brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 12ad1b1 Raw
57 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINEHOSTILERAIICHECK_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINEHOSTILERAIICHECK_H11 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 18namespace clang::tidy::misc {19 20/// Detects when objects of certain hostile RAII types persists across21/// suspension points in a coroutine. Such hostile types include scoped-lockable22/// types and types belonging to a configurable denylist.23///24///  For the user-facing documentation see:25///  https://clang.llvm.org/extra/clang-tidy/checks/misc/coroutine-hostile-raii.html26class CoroutineHostileRAIICheck : public ClangTidyCheck {27public: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 42private:43  // List of fully qualified types which should not persist across a suspension44  // point in a coroutine.45  std::vector<StringRef> RAIITypesList;46  // List of fully qualified awaitable types which are considered safe to47  // co_await.48  std::vector<StringRef> AllowedAwaitablesList;49  // List of callees whose return values are considered safe to directly50  // co_await.51  std::vector<StringRef> AllowedCallees;52};53 54} // namespace clang::tidy::misc55 56#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_COROUTINEHOSTILERAIICHECK_H57