//===--- TypeMismatchCheck.cpp - clang-tidy--------------------------------===// // // 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 "TypeMismatchCheck.h" #include "clang/Lex/Lexer.h" #include "clang/Tooling/FixIt.h" #include "llvm/ADT/StringSet.h" #include <map> usingnamespaceclang::ast_matchers; namespace clang::tidy::mpi { /// Check if a BuiltinType::Kind matches the MPI datatype. /// /// \param MultiMap datatype group /// \param Kind buffer type kind /// \param MPIDatatype name of the MPI datatype /// /// \returns true if the pair matches static bool isMPITypeMatching(const std::multimap<BuiltinType::Kind, StringRef> &MultiMap, const BuiltinType::Kind Kind, StringRef MPIDatatype) { … } /// Check if the MPI datatype is a standard type. /// /// \param MPIDatatype name of the MPI datatype /// /// \returns true if the type is a standard type static bool isStandardMPIDatatype(StringRef MPIDatatype) { … } /// Check if a BuiltinType matches the MPI datatype. /// /// \param Builtin the builtin type /// \param BufferTypeName buffer type name, gets assigned /// \param MPIDatatype name of the MPI datatype /// \param LO language options /// /// \returns true if the type matches static bool isBuiltinTypeMatching(const BuiltinType *Builtin, std::string &BufferTypeName, StringRef MPIDatatype, const LangOptions &LO) { … } /// Check if a complex float/double/long double buffer type matches /// the MPI datatype. /// /// \param Complex buffer type /// \param BufferTypeName buffer type name, gets assigned /// \param MPIDatatype name of the MPI datatype /// \param LO language options /// /// \returns true if the type matches or the buffer type is unknown static bool isCComplexTypeMatching(const ComplexType *const Complex, std::string &BufferTypeName, StringRef MPIDatatype, const LangOptions &LO) { … } /// Check if a complex<float/double/long double> templated buffer type matches /// the MPI datatype. /// /// \param Template buffer type /// \param BufferTypeName buffer type name, gets assigned /// \param MPIDatatype name of the MPI datatype /// \param LO language options /// /// \returns true if the type matches or the buffer type is unknown static bool isCXXComplexTypeMatching(const TemplateSpecializationType *const Template, std::string &BufferTypeName, StringRef MPIDatatype, const LangOptions &LO) { … } /// Check if a fixed size width buffer type matches the MPI datatype. /// /// \param Typedef buffer type /// \param BufferTypeName buffer type name, gets assigned /// \param MPIDatatype name of the MPI datatype /// /// \returns true if the type matches or the buffer type is unknown static bool isTypedefTypeMatching(const TypedefType *const Typedef, std::string &BufferTypeName, StringRef MPIDatatype) { … } /// Get the unqualified, dereferenced type of an argument. /// /// \param CE call expression /// \param Idx argument index /// /// \returns type of the argument static const Type *argumentType(const CallExpr *const CE, const size_t Idx) { … } void TypeMismatchCheck::registerMatchers(MatchFinder *Finder) { … } void TypeMismatchCheck::check(const MatchFinder::MatchResult &Result) { … } void TypeMismatchCheck::checkArguments(ArrayRef<const Type *> BufferTypes, ArrayRef<const Expr *> BufferExprs, ArrayRef<StringRef> MPIDatatypes, const LangOptions &LO) { … } void TypeMismatchCheck::onEndOfTranslationUnit() { … } } // namespace clang::tidy::mpi