brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 4a453f6 Raw
52 lines · cpp
1// REQUIRES: static-analyzer2// RUN: %check_clang_tidy %s mpi-buffer-deref %t -- -- -I %S/Inputs/type-mismatch3 4#include "mpimock.h"5 6void negativeTests() {7  char *buf;8  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);9  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->pointer [mpi-buffer-deref]10 11  unsigned **buf2;12  MPI_Send(buf2, 1, MPI_UNSIGNED, 0, 0, MPI_COMM_WORLD);13  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->pointer14 15  short buf3[1][1];16  MPI_Send(buf3, 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD);17  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: array->array18 19  long double _Complex *buf4[1];20  MPI_Send(buf4, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);21  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->array22 23  std::complex<float> *buf5[1][1];24  MPI_Send(&buf5, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);25  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->array->array->pointer26}27 28void positiveTests() {29  char buf;30  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);31 32  unsigned *buf2;33  MPI_Send(buf2, 1, MPI_UNSIGNED, 0, 0, MPI_COMM_WORLD);34 35  short buf3[1][1];36  MPI_Send(buf3[0], 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD);37 38  long double _Complex *buf4[1];39  MPI_Send(*buf4, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);40 41  long double _Complex buf5[1];42  MPI_Send(buf5, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);43 44  std::complex<float> *buf6[1][1];45  MPI_Send(*buf6[0], 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);46 47  // Referencing an array with '&' is valid, as this also points to the48  // beginning of the array.49  long double _Complex buf7[1];50  MPI_Send(&buf7, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);51}52