clang-tools 20.0.0git
NoexceptMoveConstructorCheck.h
Go to the documentation of this file.
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"
14
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
28public:
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
Generic check which checks if the bound function decl is marked with noexcept or noexcept(expr) where...
NoexceptFunctionBaseCheck(StringRef Name, ClangTidyContext *Context)
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
static constexpr const char FuncDecl[]