20 hasType(cxxRecordDecl(anyOf(
21 matchesName(
"[Ee]xception|EXCEPTION"),
22 hasAnyBase(hasType(hasCanonicalType(recordType(hasDeclaration(
23 cxxRecordDecl(matchesName(
"[Ee]xception|EXCEPTION"))
24 .bind(
"base"))))))))),
27 stmt(anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
28 hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
29 hasAncestor(expr(cxxNewExpr(hasAnyPlacementArg(anything())))),
30 allOf(hasAncestor(cxxConstructorDecl()),
31 unless(hasAncestor(cxxCatchStmt()))))))
32 .bind(
"temporary-exception-not-thrown"),
37 const auto *TemporaryExpr =
38 Result.Nodes.getNodeAs<Expr>(
"temporary-exception-not-thrown");
40 diag(TemporaryExpr->getBeginLoc(),
"suspicious exception object created but "
41 "not thrown; did you mean 'throw %0'?")
42 << TemporaryExpr->getType().getBaseTypeIdentifier()->getName();
44 if (
const auto *BaseDecl = Result.Nodes.getNodeAs<Decl>(
"base"))
45 diag(BaseDecl->getLocation(),
46 "object type inherits from base class declared here",