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