|
|
|||
File indexing completed on 2026-05-10 08:36:21
0001 //===--- BufferDerefCheck.h - clang-tidy-------------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_BUFFER_DEREF_H 0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_BUFFER_DEREF_H 0011 0012 #include "../ClangTidyCheck.h" 0013 #include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h" 0014 #include <optional> 0015 0016 namespace clang::tidy::mpi { 0017 0018 /// This check verifies if a buffer passed to an MPI (Message Passing Interface) 0019 /// function is sufficiently dereferenced. Buffers should be passed as a single 0020 /// pointer or array. As MPI function signatures specify void * for their buffer 0021 /// types, insufficiently dereferenced buffers can be passed, like for example 0022 /// as double pointers or multidimensional arrays, without a compiler warning 0023 /// emitted. 0024 /// 0025 /// For the user-facing documentation see: 0026 /// http://clang.llvm.org/extra/clang-tidy/checks/mpi/buffer-deref.html 0027 class BufferDerefCheck : public ClangTidyCheck { 0028 public: 0029 BufferDerefCheck(StringRef Name, ClangTidyContext *Context) 0030 : ClangTidyCheck(Name, Context) {} 0031 void registerMatchers(ast_matchers::MatchFinder *Finder) override; 0032 void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 0033 void onEndOfTranslationUnit() override; 0034 0035 private: 0036 /// Checks for all buffers in an MPI call if they are sufficiently 0037 /// dereferenced. 0038 /// 0039 /// \param BufferTypes buffer types 0040 /// \param BufferExprs buffer arguments as expressions 0041 void checkBuffers(ArrayRef<const Type *> BufferTypes, 0042 ArrayRef<const Expr *> BufferExprs); 0043 0044 enum class IndirectionType : unsigned char { Pointer, Array }; 0045 0046 std::optional<ento::mpi::MPIFunctionClassifier> FuncClassifier; 0047 }; 0048 0049 } // namespace clang::tidy::mpi 0050 0051 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_BUFFER_DEREF_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|