xref: /llvm-project/clang-tools-extra/clang-tidy/performance/NoexceptDestructorCheck.h (revision 845618cf69e89313084a4e93f8ff31d8e6ea4499)
1 //===--- NoexceptDestructorCheck.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_NOEXCEPTDESTRUCTORCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTDESTRUCTORCHECK_H
11 
12 #include "../ClangTidyCheck.h"
13 #include "NoexceptFunctionBaseCheck.h"
14 
15 namespace clang::tidy::performance {
16 
17 /// The check flags destructors not marked with `noexcept` or marked
18 /// with `noexcept(expr)` where `expr` evaluates to `false`
19 /// (but is not a `false` literal itself).
20 ///
21 /// For the user-facing documentation see:
22 /// https://clang.llvm.org/extra/clang-tidy/checks/performance/noexcept-destructor.html
23 class NoexceptDestructorCheck : public NoexceptFunctionBaseCheck {
24 public:
25   using NoexceptFunctionBaseCheck::NoexceptFunctionBaseCheck;
26 
27   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
28 
29 private:
30   DiagnosticBuilder
31   reportMissingNoexcept(const FunctionDecl *FuncDecl) final override;
32   void reportNoexceptEvaluatedToFalse(const FunctionDecl *FuncDecl,
33                                       const Expr *NoexceptExpr) final override;
34 };
35 
36 } // namespace clang::tidy::performance
37 
38 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTDESTRUCTORCHECK_H
39