=?utf-8?q?Balázs_Kéri?= <[email protected]>, =?utf-8?q?Balázs_Kéri?= <[email protected]>, =?utf-8?q?Balázs_Kéri?= <[email protected]>, =?utf-8?q?Balázs_Kéri?= <[email protected]>, =?utf-8?q?Balázs_Kéri?= <[email protected]> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================ @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "UnsafeToAllowExceptionsCheck.h" + +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "llvm/ADT/StringSet.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { +namespace { + +AST_MATCHER_P(FunctionDecl, hasAnyName, llvm::StringSet<>, Names) { + return Names.contains(Node.getNameAsString()); +} + +AST_MATCHER(FunctionDecl, isExplicitThrow) { + return isExplicitThrowExceptionSpec(Node.getExceptionSpecType()) && + Node.getExceptionSpecSourceRange().isValid(); +} + +} // namespace + +UnsafeToAllowExceptionsCheck::UnsafeToAllowExceptionsCheck( + StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context), + RawCheckedSwapFunctions( + Options.get("CheckedSwapFunctions", "swap;iter_swap;iter_move")) { + llvm::SmallVector<StringRef, 4> CheckedSwapFunctionsVec; + RawCheckedSwapFunctions.split(CheckedSwapFunctionsVec, ";", -1, false); + CheckedSwapFunctions.insert_range(CheckedSwapFunctionsVec); +} + +void UnsafeToAllowExceptionsCheck::storeOptions( + ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "CheckedSwapFunctions", RawCheckedSwapFunctions); +} + +void UnsafeToAllowExceptionsCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher( + functionDecl(allOf(isDefinition(), isExplicitThrow(), ---------------- zwuis wrote: Redundant `allOf`. Node matchers implicitly act as `allOf` matchers. https://clang.llvm.org/docs/LibASTMatchersReference.html https://github.com/llvm/llvm-project/pull/176430 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
