42 lines · c
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H11 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 not18/// 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 constructors23/// 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.html27class NoexceptMoveConstructorCheck : public NoexceptFunctionBaseCheck {28public:29 using NoexceptFunctionBaseCheck::NoexceptFunctionBaseCheck;30 31 void registerMatchers(ast_matchers::MatchFinder *Finder) override;32 33private:34 DiagnosticBuilder reportMissingNoexcept(const FunctionDecl *FuncDecl) final;35 void reportNoexceptEvaluatedToFalse(const FunctionDecl *FuncDecl,36 const Expr *NoexceptExpr) final;37};38 39} // namespace clang::tidy::performance40 41#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H42