1 //===--- TypeMismatchCheck.h - clang-tidy------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_TYPE_MISMATCH_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_TYPE_MISMATCH_H
12 #include "../ClangTidyCheck.h"
13 #include "clang/ASTMatchers/ASTMatchFinder.h"
14 #include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
17 namespace clang::tidy::mpi
{
19 /// This check verifies if buffer type and MPI (Message Passing Interface)
20 /// datatype pairs match. All MPI datatypes defined by the MPI standard (3.1)
21 /// are verified by this check. User defined typedefs, custom MPI datatypes and
22 /// null pointer constants are skipped, in the course of verification.
24 /// For the user-facing documentation see:
25 /// http://clang.llvm.org/extra/clang-tidy/checks/mpi/type-mismatch.html
26 class TypeMismatchCheck
: public ClangTidyCheck
{
28 TypeMismatchCheck(StringRef Name
, ClangTidyContext
*Context
)
29 : ClangTidyCheck(Name
, Context
) {}
31 void registerMatchers(ast_matchers::MatchFinder
*Finder
) override
;
32 void check(const ast_matchers::MatchFinder::MatchResult
&Result
) override
;
34 void onEndOfTranslationUnit() override
;
37 /// Check if the buffer type MPI datatype pairs match.
39 /// \param BufferTypes buffer types
40 /// \param BufferExprs buffer arguments as expressions
41 /// \param MPIDatatypes MPI datatype
42 /// \param LO language options
43 void checkArguments(ArrayRef
<const Type
*> BufferTypes
,
44 ArrayRef
<const Expr
*> BufferExprs
,
45 ArrayRef
<StringRef
> MPIDatatypes
, const LangOptions
&LO
);
47 std::optional
<ento::mpi::MPIFunctionClassifier
> FuncClassifier
;
50 } // namespace clang::tidy::mpi
52 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_TYPE_MISMATCH_H