1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPIBUGREPORTER_H |
16 | #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPIBUGREPORTER_H |
17 | |
18 | #include "MPITypes.h" |
19 | #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" |
20 | |
21 | namespace clang { |
22 | namespace ento { |
23 | namespace mpi { |
24 | |
25 | class MPIBugReporter { |
26 | public: |
27 | MPIBugReporter(const CheckerBase &CB) { |
28 | UnmatchedWaitBugType.reset(new BugType(&CB, "Unmatched wait", MPIError)); |
29 | DoubleNonblockingBugType.reset( |
30 | new BugType(&CB, "Double nonblocking", MPIError)); |
31 | MissingWaitBugType.reset(new BugType(&CB, "Missing wait", MPIError)); |
32 | } |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | void reportDoubleNonblocking(const CallEvent &MPICallEvent, |
43 | const Request &Req, |
44 | const MemRegion *const RequestRegion, |
45 | const ExplodedNode *const ExplNode, |
46 | BugReporter &BReporter) const; |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | void reportMissingWait(const Request &Req, |
55 | const MemRegion *const RequestRegion, |
56 | const ExplodedNode *const ExplNode, |
57 | BugReporter &BReporter) const; |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | void reportUnmatchedWait(const CallEvent &CE, |
66 | const MemRegion *const RequestRegion, |
67 | const ExplodedNode *const ExplNode, |
68 | BugReporter &BReporter) const; |
69 | |
70 | private: |
71 | const std::string MPIError = "MPI Error"; |
72 | |
73 | |
74 | std::unique_ptr<BugType> UnmatchedWaitBugType; |
75 | std::unique_ptr<BugType> MissingWaitBugType; |
76 | std::unique_ptr<BugType> DoubleNonblockingBugType; |
77 | |
78 | |
79 | |
80 | class RequestNodeVisitor : public BugReporterVisitor { |
81 | public: |
82 | RequestNodeVisitor(const MemRegion *const MemoryRegion, |
83 | const std::string &ErrText) |
84 | : RequestRegion(MemoryRegion), ErrorText(ErrText) {} |
85 | |
86 | void Profile(llvm::FoldingSetNodeID &ID) const override { |
87 | static int X = 0; |
88 | ID.AddPointer(&X); |
89 | ID.AddPointer(RequestRegion); |
90 | } |
91 | |
92 | std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N, |
93 | BugReporterContext &BRC, |
94 | BugReport &BR) override; |
95 | |
96 | private: |
97 | const MemRegion *const RequestRegion; |
98 | bool IsNodeFound = false; |
99 | std::string ErrorText; |
100 | }; |
101 | }; |
102 | |
103 | } |
104 | } |
105 | } |
106 | |
107 | #endif |
108 | |