1//===--- NoexceptMoveConstructorCheck.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_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H
11
12#include "../ClangTidyCheck.h"
13#include "NoexceptFunctionBaseCheck.h"
14
15namespace clang::tidy::performance {
16
17/// The check flags user-defined move constructors and assignment operators not
18/// marked with `noexcept` or marked with `noexcept(expr)` where `expr`
19/// evaluates to `false` (but is not a `false` literal itself).
20///
21/// Move constructors of all the types used with STL containers, for example,
22/// need to be declared `noexcept`. Otherwise STL will choose copy constructors
23/// instead. The same is valid for move assignment operations.
24///
25/// For the user-facing documentation see:
26/// https://clang.llvm.org/extra/clang-tidy/checks/performance/noexcept-move-constructor.html
27class NoexceptMoveConstructorCheck : public NoexceptFunctionBaseCheck {
28public:
29 using NoexceptFunctionBaseCheck::NoexceptFunctionBaseCheck;
30
31 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
32
33private:
34 DiagnosticBuilder
35 reportMissingNoexcept(const FunctionDecl *FuncDecl) final override;
36 void reportNoexceptEvaluatedToFalse(const FunctionDecl *FuncDecl,
37 const Expr *NoexceptExpr) final override;
38};
39
40} // namespace clang::tidy::performance
41
42#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H
43

source code of clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.h