=?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]>, =?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,97 @@ +//===----------------------------------------------------------------------===// +// +// 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 "CastToStructCheck.h" +#include "../utils/Matchers.h" +#include "../utils/OptionsUtils.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::bugprone { + +namespace { + +AST_MATCHER(Type, charType) { return Node.isCharType(); } +AST_MATCHER(Type, unionType) { return Node.isUnionType(); } + +} // namespace + +CastToStructCheck::CastToStructCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context), + IgnoredCasts( + utils::options::parseStringList(Options.get("IgnoredCasts", ""))) { + IgnoredCastsRegex.reserve(IgnoredCasts.size()); + for (const auto &Str : IgnoredCasts) { + std::string WholeWordRegex; + WholeWordRegex.reserve(Str.size() + 2); + WholeWordRegex.push_back('^'); + WholeWordRegex.append(Str); + WholeWordRegex.push_back('$'); + IgnoredCastsRegex.emplace_back(WholeWordRegex); + } +} + +void CastToStructCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IgnoredCasts", + utils::options::serializeStringList(IgnoredCasts)); +} + +void CastToStructCheck::registerMatchers(MatchFinder *Finder) { + auto FromPointee = + qualType(hasUnqualifiedDesugaredType(type().bind("FromType")), + unless(voidType()), unless(charType()), unless(unionType())) + .bind("FromPointee"); ---------------- zwuis wrote: Unused binding. Ditto for "ToPointee". https://github.com/llvm/llvm-project/pull/153428 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
