clang-tools
20.0.0git
llvm-project
clang-tools-extra
clang-tidy
performance
NoexceptFunctionBaseCheck.h
Go to the documentation of this file.
1
//===--- NoexceptFunctionCheck.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_NOEXCEPTFUNCTIONCHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTFUNCTIONCHECK_H
11
12
#include "../ClangTidyCheck.h"
13
#include "../utils/ExceptionSpecAnalyzer.h"
14
#include "clang/AST/Decl.h"
15
#include "llvm/ADT/StringRef.h"
16
17
namespace
clang::tidy::performance
{
18
19
/// Generic check which checks if the bound function decl is
20
/// marked with `noexcept` or `noexcept(expr)` where `expr` evaluates to
21
/// `false`.
22
class
NoexceptFunctionBaseCheck
:
public
ClangTidyCheck
{
23
public
:
24
NoexceptFunctionBaseCheck
(StringRef
Name
,
ClangTidyContext
*Context)
25
:
ClangTidyCheck
(
Name
, Context) {}
26
27
bool
isLanguageVersionSupported
(
const
LangOptions &LangOpts)
const override
{
28
return
LangOpts.CPlusPlus11 && LangOpts.CXXExceptions;
29
}
30
void
31
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
final
override
;
32
std::optional<TraversalKind>
getCheckTraversalKind
()
const override
{
33
return
TK_IgnoreUnlessSpelledInSource;
34
}
35
36
protected
:
37
virtual
DiagnosticBuilder
38
reportMissingNoexcept
(
const
FunctionDecl *
FuncDecl
) = 0;
39
virtual
void
reportNoexceptEvaluatedToFalse
(
const
FunctionDecl *
FuncDecl
,
40
const
Expr *NoexceptExpr) = 0;
41
42
static
constexpr
StringRef
BindFuncDeclName
=
"FuncDecl"
;
43
44
private
:
45
utils::ExceptionSpecAnalyzer
SpecAnalyzer;
46
};
47
48
}
// namespace clang::tidy::performance
49
50
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTFUNCTIONCHECK_H
Name
llvm::SmallString< 256U > Name
Definition:
ChainedComparisonCheck.cpp:42
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:53
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::performance::NoexceptFunctionBaseCheck
Generic check which checks if the bound function decl is marked with noexcept or noexcept(expr) where...
Definition:
NoexceptFunctionBaseCheck.h:22
clang::tidy::performance::NoexceptFunctionBaseCheck::BindFuncDeclName
static constexpr StringRef BindFuncDeclName
Definition:
NoexceptFunctionBaseCheck.h:42
clang::tidy::performance::NoexceptFunctionBaseCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) final override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
NoexceptFunctionBaseCheck.cpp:19
clang::tidy::performance::NoexceptFunctionBaseCheck::NoexceptFunctionBaseCheck
NoexceptFunctionBaseCheck(StringRef Name, ClangTidyContext *Context)
Definition:
NoexceptFunctionBaseCheck.h:24
clang::tidy::performance::NoexceptFunctionBaseCheck::reportNoexceptEvaluatedToFalse
virtual void reportNoexceptEvaluatedToFalse(const FunctionDecl *FuncDecl, const Expr *NoexceptExpr)=0
clang::tidy::performance::NoexceptFunctionBaseCheck::isLanguageVersionSupported
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
Definition:
NoexceptFunctionBaseCheck.h:27
clang::tidy::performance::NoexceptFunctionBaseCheck::getCheckTraversalKind
std::optional< TraversalKind > getCheckTraversalKind() const override
Definition:
NoexceptFunctionBaseCheck.h:32
clang::tidy::performance::NoexceptFunctionBaseCheck::reportMissingNoexcept
virtual DiagnosticBuilder reportMissingNoexcept(const FunctionDecl *FuncDecl)=0
clang::tidy::utils::ExceptionSpecAnalyzer
This class analysis if a FunctionDecl has been declared implicitly through defaulting or explicitly a...
Definition:
ExceptionSpecAnalyzer.h:21
clang::tidy::performance
Definition:
AvoidEndlCheck.cpp:20
FuncDecl
static constexpr const char FuncDecl[]
Definition:
utils/UseRangesCheck.cpp:37
Generated on Wed Dec 25 2024 05:24:22 for clang-tools by
1.9.6