1 | //===--- CapturingThisInMemberVariableCheck.h - clang-tidy ------*- C++ -*-===// |
---|---|
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-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CAPTURINGTHISINMEMBERVARIABLECHECK_H |
10 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CAPTURINGTHISINMEMBERVARIABLECHECK_H |
11 | |
12 | #include "../ClangTidyCheck.h" |
13 | #include "clang/AST/ASTTypeTraits.h" |
14 | #include <optional> |
15 | |
16 | namespace clang::tidy::bugprone { |
17 | |
18 | /// Finds lambda captures that capture the ``this`` pointer and store it as |
19 | /// class members without handle the copy and move constructors and the |
20 | /// assignments. |
21 | /// |
22 | /// For the user-facing documentation see: |
23 | /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/capturing-this-in-member-variable.html |
24 | class CapturingThisInMemberVariableCheck : public ClangTidyCheck { |
25 | public: |
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 | |
37 | private: |
38 | ///< store the function wrapper types |
39 | const std::vector<StringRef> FunctionWrapperTypes; |
40 | const std::vector<StringRef> BindFunctions; |
41 | }; |
42 | |
43 | } // namespace clang::tidy::bugprone |
44 | |
45 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_CAPTURINGTHISINMEMBERVARIABLECHECK_H |
46 |