Fix false positive in `bugprone-throw-keyword-missing` check

Fixes PR#52400. The tests for bugprone-throw-keyword-missing actually
already contain exceptions as class members, but not as members with
initializers, which was probably just an oversight.
This commit is contained in:
Fabian Wolff 2021-11-16 07:09:17 -05:00 committed by Aaron Ballman
parent 098c01c132
commit 738e7f1231
2 changed files with 2 additions and 1 deletions

View File

@ -26,7 +26,7 @@ void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
isSameOrDerivedFrom(matchesName("[Ee]xception|EXCEPTION")))),
unless(anyOf(hasAncestor(stmt(
anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
hasAncestor(varDecl()),
hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
allOf(hasAncestor(CtorInitializerList),
unless(hasAncestor(cxxCatchStmt()))))))
.bind("temporary-exception-not-thrown"),

View File

@ -118,6 +118,7 @@ void localVariableInitTest() {
class CtorInitializerListTest {
RegularException exc;
RegularException exc2{};
CtorInitializerListTest() : exc(RegularException()) {}