UNSUPPORT test on 64-bit AIX too
[llvm-project.git] / clang-tools-extra / clang-tidy / cert / ThrownExceptionTypeCheck.cpp
blob6b2579bdfdb7dfc34f401ee0ae273e503dad40b2
1 //===--- ThrownExceptionTypeCheck.cpp - clang-tidy-------------------------===//
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 //===----------------------------------------------------------------------===//
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 {
17 namespace tidy {
18 namespace cert {
20 void ThrownExceptionTypeCheck::registerMatchers(MatchFinder *Finder) {
21 Finder->addMatcher(
22 traverse(
23 TK_AsIs,
24 cxxThrowExpr(has(ignoringParenImpCasts(
25 cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
26 isCopyConstructor(), unless(isNoThrow()))))
27 .bind("expr"))))),
28 this);
31 void ThrownExceptionTypeCheck::check(const MatchFinder::MatchResult &Result) {
32 const auto *E = Result.Nodes.getNodeAs<Expr>("expr");
33 diag(E->getExprLoc(),
34 "thrown exception type is not nothrow copy constructible");
37 } // namespace cert
38 } // namespace tidy
39 } // namespace clang