| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPICHECKER_H |
| 18 | #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_MPICHECKER_MPICHECKER_H |
| 19 | |
| 20 | #include "MPIBugReporter.h" |
| 21 | #include "MPITypes.h" |
| 22 | #include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h" |
| 23 | #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" |
| 24 | #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" |
| 25 | |
| 26 | namespace clang { |
| 27 | namespace ento { |
| 28 | namespace mpi { |
| 29 | |
| 30 | class MPIChecker : public Checker<check::PreCall, check::DeadSymbols> { |
| 31 | public: |
| 32 | MPIChecker() : BReporter(*this) {} |
| 33 | |
| 34 | |
| 35 | void checkPreCall(const CallEvent &CE, CheckerContext &Ctx) const { |
| 36 | dynamicInit(Ctx); |
| 37 | checkUnmatchedWaits(CE, Ctx); |
| 38 | checkDoubleNonblocking(CE, Ctx); |
| 39 | } |
| 40 | |
| 41 | void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &Ctx) const { |
| 42 | dynamicInit(Ctx); |
| 43 | checkMissingWaits(SymReaper, Ctx); |
| 44 | } |
| 45 | |
| 46 | void dynamicInit(CheckerContext &Ctx) const { |
| 47 | if (FuncClassifier) |
| 48 | return; |
| 49 | const_cast<std::unique_ptr<MPIFunctionClassifier> &>(FuncClassifier) |
| 50 | .reset(new MPIFunctionClassifier{Ctx.getASTContext()}); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | void checkDoubleNonblocking(const clang::ento::CallEvent &PreCallEvent, |
| 59 | clang::ento::CheckerContext &Ctx) const; |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | void checkUnmatchedWaits(const clang::ento::CallEvent &PreCallEvent, |
| 67 | clang::ento::CheckerContext &Ctx) const; |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | void checkMissingWaits(clang::ento::SymbolReaper &SymReaper, |
| 73 | clang::ento::CheckerContext &Ctx) const; |
| 74 | |
| 75 | private: |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | void allRegionsUsedByWait( |
| 85 | llvm::SmallVector<const clang::ento::MemRegion *, 2> &ReqRegions, |
| 86 | const clang::ento::MemRegion *const MR, const clang::ento::CallEvent &CE, |
| 87 | clang::ento::CheckerContext &Ctx) const; |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | const clang::ento::MemRegion * |
| 94 | topRegionUsedByWait(const clang::ento::CallEvent &CE) const; |
| 95 | |
| 96 | const std::unique_ptr<MPIFunctionClassifier> FuncClassifier; |
| 97 | MPIBugReporter BReporter; |
| 98 | }; |
| 99 | |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | #endif |
| 105 | |