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 "../ClangTidyCheck.h"
13
14namespace clang::tidy::cppcoreguidelines {
15
16/// Flags slicing (incomplete copying of an object's state) of member variables
17/// or vtable. See:
18/// - https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
19/// for the former, and
20/// - https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references
21/// for the latter
22///
23/// For the user-facing documentation see:
24/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/slicing.html
25class SlicingCheck : public ClangTidyCheck {
26public:
27 SlicingCheck(StringRef Name, ClangTidyContext *Context)
28 : ClangTidyCheck(Name, Context) {}
29 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
30 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
31
32private:
33 void diagnoseSlicedOverriddenMethods(const Expr &Call,
34 const CXXRecordDecl &DerivedDecl,
35 const CXXRecordDecl &BaseDecl);
36};
37
38} // namespace clang::tidy::cppcoreguidelines
39
40#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SLICING_H
41

source code of clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.h