================
@@ -54,20 +63,30 @@ void
ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "FunctionsThatShouldNotThrow",
RawFunctionsThatShouldNotThrow);
Options.store(Opts, "IgnoredExceptions", RawIgnoredExceptions);
+ Options.store(Opts, "CheckedSwapFunctions", RawCheckedSwapFunctions);
+ Options.store(Opts, "CheckDestructors", CheckDestructors);
+ Options.store(Opts, "CheckMoveMemberFunctions", CheckMoveMemberFunctions);
+ Options.store(Opts, "CheckMain", CheckMain);
+ Options.store(Opts, "CheckNothrowFunctions", CheckNothrowFunctions);
}
void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) {
+ ast_matchers::internal::Matcher<FunctionDecl> Nothing = unless(anything());
Finder->addMatcher(
functionDecl(
isDefinition(),
- anyOf(isNoThrow(),
- allOf(anyOf(cxxDestructorDecl(),
- cxxConstructorDecl(isMoveConstructor()),
- cxxMethodDecl(isMoveAssignmentOperator()),
isMain(),
- allOf(hasAnyName("swap", "iter_swap", "iter_move"),
- hasAtLeastOneParameter())),
- unless(isExplicitThrow())),
- isEnabled(FunctionsThatShouldNotThrow)))
+ anyOf(
+ CheckNothrowFunctions ? isNoThrow() : Nothing,
----------------
zwuis wrote:
Can we use something like this to simplify further?
```cpp
auto MatchIf = [](bool Enabled, auto Matcher) {
return Enabled ? Matcher : Nothing;
};
```
https://github.com/llvm/llvm-project/pull/164081
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits