1//===-- MPITypes.h - Functionality to model MPI concepts --------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file provides definitions to model concepts of MPI. The mpi::Request
11/// class defines a wrapper class, in order to make MPI requests trackable for
12/// path-sensitive analysis.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPITYPES_H
17#define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPITYPES_H
18
19#include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
20#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
21#include "llvm/ADT/SmallSet.h"
22
23namespace clang {
24namespace ento {
25namespace mpi {
26
27class Request {
28public:
29 enum State : unsigned char { Nonblocking, Wait };
30
31 Request(State S) : CurrentState{S} {}
32
33 void Profile(llvm::FoldingSetNodeID &Id) const {
34 Id.AddInteger(I: CurrentState);
35 }
36
37 bool operator==(const Request &ToCompare) const {
38 return CurrentState == ToCompare.CurrentState;
39 }
40
41 const State CurrentState;
42};
43
44// The RequestMap stores MPI requests which are identified by their memory
45// region. Requests are used in MPI to complete nonblocking operations with wait
46// operations. A custom map implementation is used, in order to make it
47// available in an arbitrary amount of translation units.
48struct RequestMap {};
49typedef llvm::ImmutableMap<const clang::ento::MemRegion *,
50 clang::ento::mpi::Request>
51 RequestMapImpl;
52
53} // end of namespace: mpi
54
55template <>
56struct ProgramStateTrait<mpi::RequestMap>
57 : public ProgramStatePartialTrait<mpi::RequestMapImpl> {
58 static void *GDMIndex() {
59 static int index = 0;
60 return &index;
61 }
62};
63
64} // end of namespace: ento
65} // end of namespace: clang
66#endif
67

source code of clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h