clang-tools 10.0.0

SlicingCheck.h
Go to the documentation of this file.
1 //===--- SlicingCheck.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_CPPCOREGUIDELINES_SLICING_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SLICING_H
11
12 #include "../ClangTidy.h"
13
14 namespace clang {
15 namespace tidy {
16 namespace cppcoreguidelines {
17
18 /// Flags slicing (incomplete copying of an object's state) of member variables
19 /// or vtable. See:
20 /// - https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
21 /// for the former, and
22 /// - https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references
23 /// for the latter
24 ///
25 /// For the user-facing documentation see:
26 /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-slicing.html
27 class SlicingCheck : public ClangTidyCheck {
28 public:
29 SlicingCheck(StringRef Name, ClangTidyContext *Context)
30 : ClangTidyCheck(Name, Context) {}
31 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
32 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
33
34 private:
35 void DiagnoseSlicedOverriddenMethods(const Expr &call,
36 const CXXRecordDecl &DerivedDecl,
37 const CXXRecordDecl &BaseDecl);
38 };
39
40 } // namespace cppcoreguidelines
41 } // namespace tidy
42 } // namespace clang
43
44 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SLICING_H
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:47
clang::tidy::cppcoreguidelines::SlicingCheck::SlicingCheck
SlicingCheck(StringRef Name, ClangTidyContext *Context)
Definition: SlicingCheck.h:29
clang::tidy::cppcoreguidelines::SlicingCheck
Flags slicing (incomplete copying of an object&#39;s state) of member variables or vtable.
Definition: SlicingCheck.h:27
clang::tidy::cppcoreguidelines::SlicingCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: SlicingCheck.cpp:99
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
clang::tidy::cppcoreguidelines::SlicingCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: SlicingCheck.cpp:21
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:77