================ @@ -0,0 +1,31 @@ +//===--- SuspiciousPointerArithmeticsUsingSizeofCheck.h -------*- C++ -*---===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSPOINTERARITHMETICSUSINGSIZEOFCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSPOINTERARITHMETICSUSINGSIZEOFCHECK_H + +#include "../ClangTidyCheck.h" + +namespace clang::tidy::bugprone { + +/// Finds suspicious pointer arithmetic calculations where the pointer is +/// offset by an alignof(), offsetof(), or sizeof() expression. +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/suspicious-pointer-arithmetics-using-sizeof.html +class SuspiciousPointerArithmeticsUsingSizeofCheck : public ClangTidyCheck { +public: + SuspiciousPointerArithmeticsUsingSizeofCheck(StringRef Name, + ClangTidyContext *Context); + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; ---------------- nicovank wrote:
``` bool isLanguageVersionSupported(const LangOptions &LangOpts) const override ``` Support C and C++? Maybe add a C++ test file testing the three operations, also testing with template types. https://github.com/llvm/llvm-project/pull/106061 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits