brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 9acc3f2 Raw
46 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_BUGPRONE_CAPTURINGTHISINMEMBERVARIABLECHECK_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CAPTURINGTHISINMEMBERVARIABLECHECK_H11 12#include "../ClangTidyCheck.h"13#include "clang/AST/ASTTypeTraits.h"14#include <optional>15 16namespace clang::tidy::bugprone {17 18/// Finds lambda captures that capture the ``this`` pointer and store it as19/// class members without handle the copy and move constructors and the20/// assignments.21///22/// For the user-facing documentation see:23/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/capturing-this-in-member-variable.html24class CapturingThisInMemberVariableCheck : public ClangTidyCheck {25public:26  CapturingThisInMemberVariableCheck(StringRef Name, ClangTidyContext *Context);27  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;28  void registerMatchers(ast_matchers::MatchFinder *Finder) override;29  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;30  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {31    return LangOpts.CPlusPlus11;32  }33  std::optional<TraversalKind> getCheckTraversalKind() const override {34    return TraversalKind::TK_IgnoreUnlessSpelledInSource;35  }36 37private:38  ///< store the function wrapper types39  const std::vector<StringRef> FunctionWrapperTypes;40  const std::vector<StringRef> BindFunctions;41};42 43} // namespace clang::tidy::bugprone44 45#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CAPTURINGTHISINMEMBERVARIABLECHECK_H46