1 //===--- SlicingCheck.h - clang-tidy-----------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SLICING_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SLICING_H
12 #include "../ClangTidyCheck.h"
14 namespace clang::tidy::cppcoreguidelines
{
16 /// Flags slicing (incomplete copying of an object's state) of member variables
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
23 /// For the user-facing documentation see:
24 /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/slicing.html
25 class SlicingCheck
: public ClangTidyCheck
{
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
;
33 void diagnoseSlicedOverriddenMethods(const Expr
&Call
,
34 const CXXRecordDecl
&DerivedDecl
,
35 const CXXRecordDecl
&BaseDecl
);
38 } // namespace clang::tidy::cppcoreguidelines
40 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SLICING_H