1 //===--- NoexceptMoveConstructorCheck.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_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H
12 #include "../ClangTidyCheck.h"
13 #include "NoexceptFunctionBaseCheck.h"
15 namespace clang::tidy::performance
{
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).
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.
25 /// For the user-facing documentation see:
26 /// https://clang.llvm.org/extra/clang-tidy/checks/performance/noexcept-move-constructor.html
27 class NoexceptMoveConstructorCheck
: public NoexceptFunctionBaseCheck
{
29 using NoexceptFunctionBaseCheck::NoexceptFunctionBaseCheck
;
31 void registerMatchers(ast_matchers::MatchFinder
*Finder
) override
;
35 reportMissingNoexcept(const FunctionDecl
*FuncDecl
) final override
;
36 void reportNoexceptEvaluatedToFalse(const FunctionDecl
*FuncDecl
,
37 const Expr
*NoexceptExpr
) final override
;
40 } // namespace clang::tidy::performance
42 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H