46 BReporter.reportDoubleNonblocking(PreCallEvent, *Req, MR, ErrorNode,
61 const MemRegion *
const MR = topRegionUsedByWait(PreCallEvent);
71 allRegionsUsedByWait(ReqRegions, MR, PreCallEvent, Ctx);
72 if (ReqRegions.empty())
79 for (
const auto &ReqRegion : ReqRegions) {
88 BReporter.reportUnmatchedWait(PreCallEvent, ReqRegion, ErrorNode,
103 const auto &Requests = State->get<
RequestMap>();
104 if (Requests.isEmpty())
110 for (
const auto &Req : ReqMap) {
118 BReporter.reportMissingWait(Req.second, Req.first, ErrorNode,
140 return (
const MemRegion *)
nullptr;
144void MPIChecker::allRegionsUsedByWait(
145 llvm::SmallVector<const MemRegion *, 2> &ReqRegions,
146 const MemRegion *
const MR,
const CallEvent &CE, CheckerContext &Ctx)
const {
150 if (FuncClassifier->isMPI_Waitall(CE.getCalleeIdentifier())) {
151 const SubRegion *SuperRegion{
nullptr};
152 if (
const ElementRegion *
const ER = MR->getAs<ElementRegion>()) {
158 ReqRegions.push_back(MR);
163 Ctx.getState(), SuperRegion, Ctx.getSValBuilder(),
164 CE.getArgExpr(1)->getType()->getPointeeType());
165 const llvm::APSInt &ArrSize =
166 ElementCount.castAs<nonloc::ConcreteInt>().getValue();
168 for (
size_t i = 0; i < ArrSize; ++i) {
169 const NonLoc Idx = Ctx.getSValBuilder().makeArrayIndex(i);
171 const ElementRegion *
const ER = RegionManager.getElementRegion(
172 CE.getArgExpr(1)->getType()->getPointeeType(), Idx, SuperRegion,
173 Ctx.getASTContext());
175 ReqRegions.push_back(ER->getAs<MemRegion>());
177 }
else if (FuncClassifier->isMPI_Wait(CE.getCalleeIdentifier())) {
178 ReqRegions.push_back(MR);
187void clang::ento::registerMPIChecker(CheckerManager &MGR) {
191bool 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.
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 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)
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)