1 //===--- ThrownExceptionTypeCheck.cpp - clang-tidy-------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "ThrownExceptionTypeCheck.h"
10 #include "../utils/Matchers.h"
11 #include "clang/AST/ASTContext.h"
12 #include "clang/ASTMatchers/ASTMatchFinder.h"
14 using namespace clang::ast_matchers
;
16 namespace clang::tidy::cert
{
18 void ThrownExceptionTypeCheck::registerMatchers(MatchFinder
*Finder
) {
22 cxxThrowExpr(has(ignoringParenImpCasts(
23 cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
24 isCopyConstructor(), unless(isNoThrow()))))
29 void ThrownExceptionTypeCheck::check(const MatchFinder::MatchResult
&Result
) {
30 const auto *E
= Result
.Nodes
.getNodeAs
<Expr
>("expr");
32 "thrown exception type is not nothrow copy constructible");
35 } // namespace clang::tidy::cert