clang-tools 20.0.0git
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 "../ClangTidyCheck.h"
13
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
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
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Flags slicing (incomplete copying of an object's state) of member variables or vtable.
Definition: SlicingCheck.h:25
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
SlicingCheck(StringRef Name, ClangTidyContext *Context)
Definition: SlicingCheck.h:27
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.