Clang Project

clang_source_code/test/Analysis/MemRegion.cpp
1// RUN: %clang_analyze_cc1 -analyzer-checker=optin.mpi.MPI-Checker -verify %s
2
3#include "MPIMock.h"
4
5// Use MPI-Checker to test 'getDescriptiveName', as the checker uses the
6// function for diagnostics.
7void testGetDescriptiveName() {
8  int rank = 0;
9  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
10  MPI_Request sendReq1;
11  MPI_Wait(&sendReq1, MPI_STATUS_IGNORE); // expected-warning{{Request 'sendReq1' has no matching nonblocking call.}}
12}
13
14void testGetDescriptiveName2() {
15  int rank = 0;
16  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
17  MPI_Request sendReq1[10][10][10];
18  MPI_Wait(&sendReq1[1][7][9], MPI_STATUS_IGNORE); // expected-warning{{Request 'sendReq1[1][7][9]' has no matching nonblocking call.}}
19}
20
21void testGetDescriptiveName3() {
22  int rank = 0;
23  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
24  typedef struct { MPI_Request req; } ReqStruct;
25  ReqStruct rs;
26  MPI_Request *r = &rs.req;
27  MPI_Wait(r, MPI_STATUS_IGNORE); // expected-warning{{Request 'rs.req' has no matching nonblocking call.}}
28}
29
30void testGetDescriptiveName4() {
31  int rank = 0;
32  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
33  typedef struct { MPI_Request req[2][2]; } ReqStruct;
34  ReqStruct rs;
35  MPI_Request *r = &rs.req[0][1];
36  MPI_Wait(r, MPI_STATUS_IGNORE); // expected-warning{{Request 'rs.req[0][1]' has no matching nonblocking call.}}
37}
38
39void testGetDescriptiveName5() {
40  int rank = 0;
41  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
42  typedef struct { MPI_Request req; } ReqStructInner;
43  typedef struct  { ReqStructInner req; } ReqStruct;
44  ReqStruct rs;
45  MPI_Request *r = &rs.req.req;
46  MPI_Wait(r, MPI_STATUS_IGNORE); // expected-warning{{Request 'rs.req.req' has no matching nonblocking call.}}
47}
48