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
16namespace 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
24class 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 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

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of clang-tools-extra/clang-tidy/bugprone/CapturingThisInMemberVariableCheck.h