Lines Matching refs:Call
287 static bool isStandardNewDelete(const CallEvent &Call) { in isStandardNewDelete() argument
288 if (!Call.getDecl() || !isa<FunctionDecl>(Call.getDecl())) in isStandardNewDelete()
290 return isStandardNewDelete(cast<FunctionDecl>(Call.getDecl())); in isStandardNewDelete()
333 void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
334 void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
335 void checkNewAllocator(const CXXAllocatorCall &Call, CheckerContext &C) const;
336 void checkPostObjCMessage(const ObjCMethodCall &Call, CheckerContext &C) const;
348 const CallEvent *Call,
352 const CallEvent *Call,
370 void NAME(const CallEvent &Call, CheckerContext &C) const;
388 void checkRealloc(const CallEvent &Call, CheckerContext &C,
392 const CallEvent &Call, CheckerContext &C)>;
401 bool isFreeingCall(const CallEvent &Call) const;
444 bool isMemCall(const CallEvent &Call) const;
459 processNewAllocation(const CXXAllocatorCall &Call, CheckerContext &C,
471 ProcessZeroAllocCheck(const CallEvent &Call, const unsigned IndexOfSizeArg,
492 MallocMemReturnsAttr(CheckerContext &C, const CallEvent &Call,
505 MallocMemAux(CheckerContext &C, const CallEvent &Call, const Expr *SizeEx,
518 MallocMemAux(CheckerContext &C, const CallEvent &Call, SVal Size, SVal Init,
524 performKernelMalloc(const CallEvent &Call, CheckerContext &C,
545 const CallEvent &Call,
569 FreeMemAux(CheckerContext &C, const CallEvent &Call, ProgramStateRef State,
593 FreeMemAux(CheckerContext &C, const Expr *ArgExpr, const CallEvent &Call,
611 ReallocMemAux(CheckerContext &C, const CallEvent &Call, bool ShouldFreeOnFail,
630 CallocMem(CheckerContext &C, const CallEvent &Call, ProgramStateRef State);
634 bool suppressDeallocationsInSuspiciousContexts(const CallEvent &Call,
658 bool mayFreeAnyEscapedMemoryOrIsModeledExplicitly(const CallEvent *Call,
666 const CallEvent *Call, PointerEscapeKind Kind,
795 bool isFreeingCallAsWritten(const CallExpr &Call) const { in isFreeingCallAsWritten()
796 if (Checker.FreeingMemFnMap.lookupAsWritten(Call) || in isFreeingCallAsWritten()
797 Checker.ReallocatingMemFnMap.lookupAsWritten(Call)) in isFreeingCallAsWritten()
801 llvm::dyn_cast_or_null<FunctionDecl>(Call.getCalleeDecl())) in isFreeingCallAsWritten()
831 if (const auto *Call = Match.getNodeAs<CallExpr>("call")) in doesFnIntendToHandleOwnership() local
832 if (isFreeingCallAsWritten(*Call)) in doesFnIntendToHandleOwnership()
875 const ObjCMethodCall &Call, in maybeEmitNoteForObjCSelf() argument
883 const CXXConstructorCall &Call, in maybeEmitNoteForCXXThis() argument
890 maybeEmitNoteForParameters(PathSensitiveBugReport &R, const CallEvent &Call, in maybeEmitNoteForParameters() argument
896 ArrayRef<ParmVarDecl *> Parameters = Call.parameters(); in maybeEmitNoteForParameters()
897 for (unsigned I = 0; I < Call.getNumArgs() && I < Parameters.size(); ++I) { in maybeEmitNoteForParameters()
898 SVal V = Call.getArgSVal(I); in maybeEmitNoteForParameters()
1099 bool MallocChecker::isFreeingCall(const CallEvent &Call) const { in isFreeingCall()
1100 if (FreeingMemFnMap.lookup(Call) || ReallocatingMemFnMap.lookup(Call)) in isFreeingCall()
1103 if (const auto *Func = dyn_cast_or_null<FunctionDecl>(Call.getDecl())) in isFreeingCall()
1109 bool MallocChecker::isMemCall(const CallEvent &Call) const { in isMemCall()
1110 if (FreeingMemFnMap.lookup(Call) || AllocatingMemFnMap.lookup(Call) || in isMemCall()
1111 ReallocatingMemFnMap.lookup(Call)) in isMemCall()
1117 const auto *Func = dyn_cast<FunctionDecl>(Call.getDecl()); in isMemCall()
1122 MallocChecker::performKernelMalloc(const CallEvent &Call, CheckerContext &C, in performKernelMalloc() argument
1171 if (Call.getNumArgs() < 2) in performKernelMalloc()
1174 const Expr *FlagsEx = Call.getArgExpr(Call.getNumArgs() - 1); in performKernelMalloc()
1200 return MallocMemAux(C, Call, Call.getArgExpr(0), ZeroVal, TrueState, in performKernelMalloc()
1218 void MallocChecker::checkBasicAlloc(const CallEvent &Call, in checkBasicAlloc() argument
1221 State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State, in checkBasicAlloc()
1223 State = ProcessZeroAllocCheck(Call, 0, State); in checkBasicAlloc()
1227 void MallocChecker::checkKernelMalloc(const CallEvent &Call, in checkKernelMalloc() argument
1231 performKernelMalloc(Call, C, State); in checkKernelMalloc()
1235 State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State, in checkKernelMalloc()
1240 static bool isStandardRealloc(const CallEvent &Call) { in isStandardRealloc() argument
1241 const FunctionDecl *FD = dyn_cast<FunctionDecl>(Call.getDecl()); in isStandardRealloc()
1254 static bool isGRealloc(const CallEvent &Call) { in isGRealloc() argument
1255 const FunctionDecl *FD = dyn_cast<FunctionDecl>(Call.getDecl()); in isGRealloc()
1268 void MallocChecker::checkRealloc(const CallEvent &Call, CheckerContext &C, in checkRealloc() argument
1276 if (!isStandardRealloc(Call) && !isGRealloc(Call)) in checkRealloc()
1279 State = ReallocMemAux(C, Call, ShouldFreeOnFail, State, AF_Malloc); in checkRealloc()
1280 State = ProcessZeroAllocCheck(Call, 1, State); in checkRealloc()
1284 void MallocChecker::checkCalloc(const CallEvent &Call, in checkCalloc() argument
1287 State = CallocMem(C, Call, State); in checkCalloc()
1288 State = ProcessZeroAllocCheck(Call, 0, State); in checkCalloc()
1289 State = ProcessZeroAllocCheck(Call, 1, State); in checkCalloc()
1293 void MallocChecker::checkFree(const CallEvent &Call, CheckerContext &C) const { in checkFree() argument
1296 if (suppressDeallocationsInSuspiciousContexts(Call, C)) in checkFree()
1298 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkFree()
1303 void MallocChecker::checkAlloca(const CallEvent &Call, in checkAlloca() argument
1306 State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State, in checkAlloca()
1308 State = ProcessZeroAllocCheck(Call, 0, State); in checkAlloca()
1312 void MallocChecker::checkStrdup(const CallEvent &Call, in checkStrdup() argument
1315 const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); in checkStrdup()
1323 void MallocChecker::checkIfNameIndex(const CallEvent &Call, in checkIfNameIndex() argument
1329 MallocMemAux(C, Call, UnknownVal(), UnknownVal(), State, AF_IfNameIndex); in checkIfNameIndex()
1334 void MallocChecker::checkIfFreeNameIndex(const CallEvent &Call, in checkIfFreeNameIndex() argument
1338 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkIfFreeNameIndex()
1343 void MallocChecker::checkCXXNewOrCXXDelete(const CallEvent &Call, in checkCXXNewOrCXXDelete() argument
1347 const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); in checkCXXNewOrCXXDelete()
1351 assert(isStandardNewDelete(Call)); in checkCXXNewOrCXXDelete()
1361 MallocMemAux(C, Call, CE->getArg(0), UndefinedVal(), State, AF_CXXNew); in checkCXXNewOrCXXDelete()
1362 State = ProcessZeroAllocCheck(Call, 0, State); in checkCXXNewOrCXXDelete()
1365 State = MallocMemAux(C, Call, CE->getArg(0), UndefinedVal(), State, in checkCXXNewOrCXXDelete()
1367 State = ProcessZeroAllocCheck(Call, 0, State); in checkCXXNewOrCXXDelete()
1370 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkCXXNewOrCXXDelete()
1374 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkCXXNewOrCXXDelete()
1384 void MallocChecker::checkGMalloc0(const CallEvent &Call, in checkGMalloc0() argument
1389 State = MallocMemAux(C, Call, Call.getArgExpr(0), zeroVal, State, AF_Malloc); in checkGMalloc0()
1390 State = ProcessZeroAllocCheck(Call, 0, State); in checkGMalloc0()
1394 void MallocChecker::checkGMemdup(const CallEvent &Call, in checkGMemdup() argument
1398 MallocMemAux(C, Call, Call.getArgExpr(1), UnknownVal(), State, AF_Malloc); in checkGMemdup()
1399 State = ProcessZeroAllocCheck(Call, 1, State); in checkGMemdup()
1403 void MallocChecker::checkGMallocN(const CallEvent &Call, in checkGMallocN() argument
1407 SVal TotalSize = evalMulForBufferSize(C, Call.getArgExpr(0), Call.getArgExpr(1)); in checkGMallocN()
1408 State = MallocMemAux(C, Call, TotalSize, Init, State, AF_Malloc); in checkGMallocN()
1409 State = ProcessZeroAllocCheck(Call, 0, State); in checkGMallocN()
1410 State = ProcessZeroAllocCheck(Call, 1, State); in checkGMallocN()
1414 void MallocChecker::checkGMallocN0(const CallEvent &Call, in checkGMallocN0() argument
1419 SVal TotalSize = evalMulForBufferSize(C, Call.getArgExpr(0), Call.getArgExpr(1)); in checkGMallocN0()
1420 State = MallocMemAux(C, Call, TotalSize, Init, State, AF_Malloc); in checkGMallocN0()
1421 State = ProcessZeroAllocCheck(Call, 0, State); in checkGMallocN0()
1422 State = ProcessZeroAllocCheck(Call, 1, State); in checkGMallocN0()
1426 void MallocChecker::checkReallocN(const CallEvent &Call, in checkReallocN() argument
1429 State = ReallocMemAux(C, Call, /*ShouldFreeOnFail=*/false, State, AF_Malloc, in checkReallocN()
1431 State = ProcessZeroAllocCheck(Call, 1, State); in checkReallocN()
1432 State = ProcessZeroAllocCheck(Call, 2, State); in checkReallocN()
1436 void MallocChecker::checkOwnershipAttr(const CallEvent &Call, in checkOwnershipAttr() argument
1439 const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); in checkOwnershipAttr()
1453 State = MallocMemReturnsAttr(C, Call, I, State); in checkOwnershipAttr()
1457 State = FreeMemAttr(C, Call, I, State); in checkOwnershipAttr()
1465 void MallocChecker::checkPostCall(const CallEvent &Call, in checkPostCall() argument
1469 if (!Call.getOriginExpr()) in checkPostCall()
1474 if (const CheckFn *Callback = FreeingMemFnMap.lookup(Call)) { in checkPostCall()
1475 (*Callback)(this, Call, C); in checkPostCall()
1479 if (const CheckFn *Callback = AllocatingMemFnMap.lookup(Call)) { in checkPostCall()
1480 (*Callback)(this, Call, C); in checkPostCall()
1484 if (const CheckFn *Callback = ReallocatingMemFnMap.lookup(Call)) { in checkPostCall()
1485 (*Callback)(this, Call, C); in checkPostCall()
1489 if (isStandardNewDelete(Call)) { in checkPostCall()
1490 checkCXXNewOrCXXDelete(Call, C); in checkPostCall()
1494 checkOwnershipAttr(Call, C); in checkPostCall()
1499 const CallEvent &Call, const unsigned IndexOfSizeArg, ProgramStateRef State, in ProcessZeroAllocCheck() argument
1505 RetVal = Call.getReturnValue(); in ProcessZeroAllocCheck()
1509 if (const CallExpr *CE = dyn_cast<CallExpr>(Call.getOriginExpr())) { in ProcessZeroAllocCheck()
1512 dyn_cast<CXXNewExpr>(Call.getOriginExpr())) { in ProcessZeroAllocCheck()
1524 State->getSVal(Arg, Call.getLocationContext()).getAs<DefinedSVal>(); in ProcessZeroAllocCheck()
1603 MallocChecker::processNewAllocation(const CXXAllocatorCall &Call, in processNewAllocation() argument
1606 if (!isStandardNewDelete(Call)) in processNewAllocation()
1609 const CXXNewExpr *NE = Call.getOriginExpr(); in processNewAllocation()
1624 SVal Target = Call.getObjectUnderConstruction(); in processNewAllocation()
1626 State = ProcessZeroAllocCheck(Call, 0, State, Target); in processNewAllocation()
1630 void MallocChecker::checkNewAllocator(const CXXAllocatorCall &Call, in checkNewAllocator() argument
1634 Call, C, in checkNewAllocator()
1635 (Call.getOriginExpr()->isArray() ? AF_CXXNewArray : AF_CXXNew)); in checkNewAllocator()
1640 static bool isKnownDeallocObjCMethodName(const ObjCMethodCall &Call) { in isKnownDeallocObjCMethodName() argument
1646 StringRef FirstSlot = Call.getSelector().getNameForSlot(0); in isKnownDeallocObjCMethodName()
1652 static std::optional<bool> getFreeWhenDoneArg(const ObjCMethodCall &Call) { in getFreeWhenDoneArg() argument
1653 Selector S = Call.getSelector(); in getFreeWhenDoneArg()
1658 return !Call.getArgSVal(i).isZeroConstant(); in getFreeWhenDoneArg()
1663 void MallocChecker::checkPostObjCMessage(const ObjCMethodCall &Call, in checkPostObjCMessage() argument
1668 if (!isKnownDeallocObjCMethodName(Call)) in checkPostObjCMessage()
1671 if (std::optional<bool> FreeWhenDone = getFreeWhenDoneArg(Call)) in checkPostObjCMessage()
1675 if (Call.hasNonZeroCallbackArg()) in checkPostObjCMessage()
1680 FreeMemAux(C, Call.getArgExpr(0), Call, C.getState(), in checkPostObjCMessage()
1688 MallocChecker::MallocMemReturnsAttr(CheckerContext &C, const CallEvent &Call, in MallocMemReturnsAttr() argument
1698 return MallocMemAux(C, Call, in MallocMemReturnsAttr()
1699 Call.getArgExpr(Att->args_begin()->getASTIndex()), in MallocMemReturnsAttr()
1702 return MallocMemAux(C, Call, UnknownVal(), UndefinedVal(), State, AF_Malloc); in MallocMemReturnsAttr()
1706 const CallEvent &Call, in MallocMemAux() argument
1714 return MallocMemAux(C, Call, C.getSVal(SizeEx), Init, State, Family); in MallocMemAux()
1718 const CallEvent &Call, SVal Size, in MallocMemAux() argument
1724 const Expr *CE = Call.getOriginExpr(); in MallocMemAux()
1781 const CallEvent &Call, in FreeMemAttr() argument
1794 FreeMemAux(C, Call, State, Arg.getASTIndex(), in FreeMemAttr()
1804 const CallEvent &Call, in FreeMemAux() argument
1812 if (Call.getNumArgs() < (Num + 1)) in FreeMemAux()
1815 return FreeMemAux(C, Call.getArgExpr(Num), Call, State, Hold, in FreeMemAux()
1899 CheckerContext &C, const Expr *ArgExpr, const CallEvent &Call, in FreeMemAux() argument
1927 const Expr *ParentExpr = Call.getOriginExpr(); in FreeMemAux()
2566 MallocChecker::ReallocMemAux(CheckerContext &C, const CallEvent &Call, in ReallocMemAux() argument
2572 const CallExpr *CE = cast<CallExpr>(Call.getOriginExpr()); in ReallocMemAux()
2619 C, Call, TotalSize, UndefinedVal(), StatePtrIsNull, Family); in ReallocMemAux()
2637 C, Call, StateSizeIsZero, 0, false, IsKnownToBeAllocated, Family)) in ReallocMemAux()
2642 FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocated, Family)) { in ReallocMemAux()
2645 MallocMemAux(C, Call, TotalSize, UnknownVal(), stateFree, Family); in ReallocMemAux()
2675 const CallEvent &Call, in CallocMem() argument
2680 if (Call.getNumArgs() < 2) in CallocMem()
2686 evalMulForBufferSize(C, Call.getArgExpr(0), Call.getArgExpr(1)); in CallocMem()
2688 return MallocMemAux(C, Call, TotalSize, zeroVal, State, AF_Malloc); in CallocMem()
2855 void MallocChecker::checkPreCall(const CallEvent &Call, in checkPreCall() argument
2858 if (const auto *DC = dyn_cast<CXXDeallocatorCall>(&Call)) { in checkPreCall()
2870 State = FreeMemAux(C, DE->getArgument(), Call, State, in checkPreCall()
2878 if (const auto *DC = dyn_cast<CXXDestructorCall>(&Call)) { in checkPreCall()
2885 if (const AnyFunctionCall *FC = dyn_cast<AnyFunctionCall>(&Call)) { in checkPreCall()
2890 if (ChecksEnabled[CK_MallocChecker] && isFreeingCall(Call)) in checkPreCall()
2895 if (const CXXInstanceCall *CC = dyn_cast<CXXInstanceCall>(&Call)) { in checkPreCall()
2902 for (unsigned I = 0, E = Call.getNumArgs(); I != E; ++I) { in checkPreCall()
2903 SVal ArgSVal = Call.getArgSVal(I); in checkPreCall()
2908 if (checkUseAfterFree(Sym, C, Call.getArgExpr(I))) in checkPreCall()
2998 const CallEvent &Call, CheckerContext &C) const { in suppressDeallocationsInSuspiciousContexts() argument
2999 if (Call.getNumArgs() == 0) in suppressDeallocationsInSuspiciousContexts()
3017 for (const Expr *Arg : cast<CallExpr>(Call.getOriginExpr())->arguments()) in suppressDeallocationsInSuspiciousContexts()
3116 const CallEvent *Call, in mayFreeAnyEscapedMemoryOrIsModeledExplicitly() argument
3119 assert(Call); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3126 if (!isa<SimpleFunctionCall, ObjCMethodCall>(Call)) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3130 if (const ObjCMethodCall *Msg = dyn_cast<ObjCMethodCall>(Call)) { in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3133 if (!Call->isInSystemHeader() || Call->argumentsMayEscape()) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3181 const FunctionDecl *FD = cast<SimpleFunctionCall>(Call)->getDecl(); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3187 if (isMemCall(*Call)) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3191 if (!Call->isInSystemHeader()) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3206 for (unsigned i = 1; i < Call->getNumArgs(); ++i) { in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3207 const Expr *ArgE = Call->getArgExpr(i)->IgnoreParenCasts(); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3222 if (Call->getNumArgs() >= 4 && Call->getArgSVal(4).isConstant(0)) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3230 if (Call->getNumArgs() >= 1) { in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3231 const Expr *ArgE = Call->getArgExpr(0)->IgnoreParenCasts(); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3271 if (Call->argumentsMayEscape()) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3281 const CallEvent *Call, in checkPointerEscape() argument
3283 return checkPointerEscapeAux(State, Escaped, Call, Kind, in checkPointerEscape()
3289 const CallEvent *Call, in checkConstPointerEscape() argument
3292 return checkPointerEscapeAux(State, Escaped, Call, Kind, in checkConstPointerEscape()
3303 const CallEvent *Call, PointerEscapeKind Kind, in checkPointerEscapeAux() argument
3309 !mayFreeAnyEscapedMemoryOrIsModeledExplicitly(Call, State, in checkPointerEscapeAux()
3450 CallEventRef<> Call = in VisitNode() local
3452 if (const auto *D = dyn_cast_or_null<NamedDecl>(Call->getDecl())) in VisitNode()