/** * Checks if buffer type and specified mpi datatype matches. * * @param mpiCall call to check type correspondence for */ void MPICheckerAST::checkBufferTypeMatch(const MPICall &mpiCall) const { // one pair consists of {bufferIdx, mpiDatatypeIdx} IndexPairs indexPairs = bufferDataTypeIndices(mpiCall); // for every buffer mpi-data pair in function // check if their types match for (const auto &idxPair : indexPairs) { const VarDecl *bufferArg = mpiCall.arguments()[idxPair.first].vars().front(); // collect buffer type information const mpi::TypeVisitor typeVisitor{bufferArg->getType()}; // get mpi datatype as string auto mpiDatatype = mpiCall.arguments()[idxPair.second].stmt_; StringRef mpiDatatypeString{util::sourceRangeAsStringRef( mpiDatatype->getSourceRange(), analysisManager_)}; selectTypeMatcher(typeVisitor, mpiCall, mpiDatatypeString, idxPair); } }
/** * Checks if buffer type and specified mpi datatype matches. * * @param mpiCall call to check type correspondence for */ void MPICheckerAST::checkBufferTypeMatch( const clang::CallExpr *const mpiCall) const { // one pair consists of {bufferIdx, mpiDatatypeIdx} IndexPairs indexPairs = bufferDataTypeIndices(mpiCall); // for every buffer mpi-data pair in function // check if their types match for (const auto &idxPair : indexPairs) { auto bufferType = mpiCall->getArg(idxPair.first)->IgnoreImpCasts()->getType(); // collect buffer type information const mpi::TypeVisitor typeVisitor { bufferType }; // get mpi datatype as string StringRef mpiDatatypeString{util::sourceRangeAsStringRef( mpiCall->getArg(idxPair.second)->getSourceRange(), analysisManager_)}; // check if buffer is correctly referenced if (typeVisitor.pointerCount() != 1) { bugReporter_.reportIncorrectBufferReferencing( mpiCall, idxPair, bufferType, typeVisitor.pointerCount()); } // MPI_BYTE needs no matching if (mpiDatatypeString == "MPI_BYTE") return; // if MPI type not known if (!cont::isContained(mpiTypes_, mpiDatatypeString)) return; selectTypeMatcher(typeVisitor, mpiCall, mpiDatatypeString, idxPair); } }