37 if (!isa<TypedRegion>(MR) || (ER && !isa<TypedRegion>(ER->
getSuperRegion())))
61 const MemRegion *
const MR = topRegionUsedByWait(PreCallEvent);
67 if (!isa<TypedRegion>(MR) || (ER && !isa<TypedRegion>(ER->
getSuperRegion())))
71 allRegionsUsedByWait(ReqRegions, MR, PreCallEvent, Ctx);
72 if (ReqRegions.empty())
80 for (
const auto &ReqRegion : ReqRegions) {
86 State = ErrorNode->getState();
104 const auto &Requests = State->get<
RequestMap>();
105 if (Requests.isEmpty())
112 for (
const auto &Req : ReqMap) {
118 State = ErrorNode->getState();
142 return (
const MemRegion *)
nullptr;
146void MPIChecker::allRegionsUsedByWait(
148 const MemRegion *
const MR,
const CallEvent &CE, CheckerContext &Ctx)
const {
152 if (FuncClassifier->isMPI_Waitall(CE.getCalleeIdentifier())) {
153 const SubRegion *SuperRegion{
nullptr};
154 if (
const ElementRegion *
const ER = MR->getAs<ElementRegion>()) {
155 SuperRegion = cast<SubRegion>(ER->getSuperRegion());
160 ReqRegions.push_back(MR);
165 Ctx.getState(), SuperRegion, Ctx.getSValBuilder(),
166 CE.getArgExpr(1)->getType()->getPointeeType());
167 const llvm::APSInt &ArrSize =
168 ElementCount.castAs<nonloc::ConcreteInt>().getValue();
170 for (
size_t i = 0; i < ArrSize; ++i) {
171 const NonLoc Idx = Ctx.getSValBuilder().makeArrayIndex(i);
173 const ElementRegion *
const ER = RegionManager.getElementRegion(
174 CE.getArgExpr(1)->getType()->getPointeeType(), Idx, SuperRegion,
175 Ctx.getASTContext());
177 ReqRegions.push_back(ER->getAs<MemRegion>());
179 }
else if (FuncClassifier->isMPI_Wait(CE.getCalleeIdentifier())) {
180 ReqRegions.push_back(MR);
189void clang::ento::registerMPIChecker(CheckerManager &MGR) {
193bool clang::ento::shouldRegisterMPIChecker(
const CheckerManager &mgr) {
This file defines the main class of MPI-Checker which serves as an entry point.
Represents an abstract call to a function or method along a particular path.
const IdentifierInfo * getCalleeIdentifier() const
Returns the name of the callee, if its name is a simple identifier.
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
virtual unsigned getNumArgs() const =0
Returns the number of arguments (explicit and implicit).
const ProgramStateRef & getState() const
ExplodedNode * addTransition(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generates a new transition in the program state graph (ExplodedGraph).
BugReporter & getBugReporter()
ExplodedNode * generateNonFatalErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
Tag that can use a checker name as a message provider (see SimpleProgramPointTag).
ElementRegion is used to represent both array elements and casts.
const ProgramStateRef & getState() const
MemRegion - The root abstract class for all memory regions.
virtual MemRegionManager & getMemRegionManager() const =0
const MemRegion * getAsRegion() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getSuperRegion() const
A class responsible for cleaning up unused symbols.
bool isLiveRegion(const MemRegion *region)
void reportMissingWait(const Request &Req, const MemRegion *const RequestRegion, const ExplodedNode *const ExplNode, BugReporter &BReporter) const
Report a missing wait for a nonblocking call.
void reportDoubleNonblocking(const CallEvent &MPICallEvent, const Request &Req, const MemRegion *const RequestRegion, const ExplodedNode *const ExplNode, BugReporter &BReporter) const
Report duplicate request use by nonblocking calls without intermediate wait.
void reportUnmatchedWait(const CallEvent &CE, const MemRegion *const RequestRegion, const ExplodedNode *const ExplNode, BugReporter &BReporter) const
Report a wait on a request that has not been used at all before.
void checkMissingWaits(clang::ento::SymbolReaper &SymReaper, clang::ento::CheckerContext &Ctx) const
Check if a nonblocking call is not matched by a wait.
void checkDoubleNonblocking(const clang::ento::CallEvent &PreCallEvent, clang::ento::CheckerContext &Ctx) const
Checks if a request is used by nonblocking calls multiple times in sequence without intermediate wait...
void checkUnmatchedWaits(const clang::ento::CallEvent &PreCallEvent, clang::ento::CheckerContext &Ctx) const
Checks if the request used by the wait function was not used at all before.
DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State, const MemRegion *MR, SValBuilder &SVB, QualType Ty)
The JSON file list parser is used to communicate input to InstallAPI.