@@ -71,18 +71,21 @@ void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
7171}
7272
7373void ExceptionEscapeCheck::registerMatchers (MatchFinder *Finder) {
74- ast_matchers::internal::Matcher<FunctionDecl> Nothing = unless (anything ());
74+ auto MatchIf = [](bool Enabled, const auto &Matcher) {
75+ ast_matchers::internal::Matcher<FunctionDecl> Nothing = unless (anything ());
76+ return Enabled ? Matcher : Nothing;
77+ };
7578 Finder->addMatcher (
7679 functionDecl (
7780 isDefinition (),
7881 anyOf (
79- CheckNothrowFunctions ? isNoThrow () : Nothing ,
80- allOf (anyOf (CheckDestructors ? cxxDestructorDecl () : Nothing ,
81- CheckMoveMemberFunctions
82- ? anyOf ( cxxConstructorDecl ( isMoveConstructor ()) ,
83- cxxMethodDecl ( isMoveAssignmentOperator ()))
84- : Nothing ,
85- CheckMain ? isMain () : Nothing ,
82+ MatchIf ( CheckNothrowFunctions, isNoThrow ()) ,
83+ allOf (anyOf (MatchIf ( CheckDestructors, cxxDestructorDecl ()) ,
84+ MatchIf (
85+ CheckMoveMemberFunctions ,
86+ anyOf ( cxxConstructorDecl ( isMoveConstructor ()),
87+ cxxMethodDecl ( isMoveAssignmentOperator ()))) ,
88+ MatchIf ( CheckMain, isMain ()) ,
8689 allOf (isEnabled (CheckedSwapFunctions),
8790 hasAtLeastOneParameter ())),
8891 unless (isExplicitThrow ())),
0 commit comments