clang-tools
22.0.0git
llvm-project
clang-tools-extra
clang-tidy
cert
ThrownExceptionTypeCheck.cpp
Go to the documentation of this file.
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-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
ThrownExceptionTypeCheck.h
"
10
#include "clang/AST/ASTContext.h"
11
#include "clang/ASTMatchers/ASTMatchFinder.h"
12
13
using namespace
clang::ast_matchers
;
14
15
namespace
clang::tidy::cert
{
16
17
void
ThrownExceptionTypeCheck::registerMatchers
(MatchFinder *Finder) {
18
Finder->addMatcher(
19
traverse(
20
TK_AsIs,
21
cxxThrowExpr(has(ignoringParenImpCasts(
22
cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
23
isCopyConstructor(), unless(isNoThrow()))))
24
.bind(
"expr"
))))),
25
this
);
26
}
27
28
void
ThrownExceptionTypeCheck::check
(
const
MatchFinder::MatchResult &Result) {
29
const
auto
*E = Result.Nodes.getNodeAs<Expr>(
"expr"
);
30
diag(E->getExprLoc(),
31
"thrown exception type is not nothrow copy constructible"
);
32
}
33
34
}
// namespace clang::tidy::cert
ThrownExceptionTypeCheck.h
clang::tidy::cert::ThrownExceptionTypeCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
Definition
ThrownExceptionTypeCheck.cpp:28
clang::tidy::cert::ThrownExceptionTypeCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Definition
ThrownExceptionTypeCheck.cpp:17
clang::ast_matchers
Definition
AbseilMatcher.h:13
clang::tidy::cert
Definition
CERTTidyModule.cpp:234
Generated on
for clang-tools by
1.14.0