Lines Matching refs:Call

286 static bool isStandardNewDelete(const CallEvent &Call) {  in isStandardNewDelete()  argument
287 if (!Call.getDecl() || !isa<FunctionDecl>(Call.getDecl())) in isStandardNewDelete()
289 return isStandardNewDelete(cast<FunctionDecl>(Call.getDecl())); in isStandardNewDelete()
332 void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
333 void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
334 void checkNewAllocator(const CXXAllocatorCall &Call, CheckerContext &C) const;
335 void checkPostObjCMessage(const ObjCMethodCall &Call, CheckerContext &C) const;
347 const CallEvent *Call,
351 const CallEvent *Call,
369 void NAME(const CallEvent &Call, CheckerContext &C) const;
387 void checkRealloc(const CallEvent &Call, CheckerContext &C,
391 const CallEvent &Call, CheckerContext &C)>;
400 bool isFreeingCall(const CallEvent &Call) const;
443 bool isMemCall(const CallEvent &Call) const;
458 ProgramStateRef processNewAllocation(const CXXAllocatorCall &Call,
471 static ProgramStateRef ProcessZeroAllocCheck(const CallEvent &Call,
493 ProgramStateRef MallocMemReturnsAttr(CheckerContext &C, const CallEvent &Call,
507 static ProgramStateRef MallocMemAux(CheckerContext &C, const CallEvent &Call,
522 static ProgramStateRef MallocMemAux(CheckerContext &C, const CallEvent &Call,
531 performKernelMalloc(const CallEvent &Call, CheckerContext &C,
552 ProgramStateRef FreeMemAttr(CheckerContext &C, const CallEvent &Call,
576 ProgramStateRef FreeMemAux(CheckerContext &C, const CallEvent &Call,
603 const CallEvent &Call, ProgramStateRef State,
622 ProgramStateRef ReallocMemAux(CheckerContext &C, const CallEvent &Call,
642 static ProgramStateRef CallocMem(CheckerContext &C, const CallEvent &Call,
647 bool suppressDeallocationsInSuspiciousContexts(const CallEvent &Call,
671 bool mayFreeAnyEscapedMemoryOrIsModeledExplicitly(const CallEvent *Call,
679 const CallEvent *Call,
809 bool isFreeingCallAsWritten(const CallExpr &Call) const { in isFreeingCallAsWritten()
810 if (Checker.FreeingMemFnMap.lookupAsWritten(Call) || in isFreeingCallAsWritten()
811 Checker.ReallocatingMemFnMap.lookupAsWritten(Call)) in isFreeingCallAsWritten()
815 llvm::dyn_cast_or_null<FunctionDecl>(Call.getCalleeDecl())) in isFreeingCallAsWritten()
845 if (const auto *Call = Match.getNodeAs<CallExpr>("call")) in doesFnIntendToHandleOwnership() local
846 if (isFreeingCallAsWritten(*Call)) in doesFnIntendToHandleOwnership()
889 const ObjCMethodCall &Call, in maybeEmitNoteForObjCSelf() argument
897 const CXXConstructorCall &Call, in maybeEmitNoteForCXXThis() argument
904 maybeEmitNoteForParameters(PathSensitiveBugReport &R, const CallEvent &Call, in maybeEmitNoteForParameters() argument
910 ArrayRef<ParmVarDecl *> Parameters = Call.parameters(); in maybeEmitNoteForParameters()
911 for (unsigned I = 0; I < Call.getNumArgs() && I < Parameters.size(); ++I) { in maybeEmitNoteForParameters()
912 SVal V = Call.getArgSVal(I); in maybeEmitNoteForParameters()
1113 bool MallocChecker::isFreeingCall(const CallEvent &Call) const { in isFreeingCall()
1114 if (FreeingMemFnMap.lookup(Call) || ReallocatingMemFnMap.lookup(Call)) in isFreeingCall()
1117 if (const auto *Func = dyn_cast_or_null<FunctionDecl>(Call.getDecl())) in isFreeingCall()
1123 bool MallocChecker::isMemCall(const CallEvent &Call) const { in isMemCall()
1124 if (FreeingMemFnMap.lookup(Call) || AllocatingMemFnMap.lookup(Call) || in isMemCall()
1125 ReallocatingMemFnMap.lookup(Call)) in isMemCall()
1131 const auto *Func = dyn_cast<FunctionDecl>(Call.getDecl()); in isMemCall()
1136 MallocChecker::performKernelMalloc(const CallEvent &Call, CheckerContext &C, in performKernelMalloc() argument
1179 if (Call.getNumArgs() < 2) in performKernelMalloc()
1182 const Expr *FlagsEx = Call.getArgExpr(Call.getNumArgs() - 1); in performKernelMalloc()
1209 return MallocMemAux(C, Call, Call.getArgExpr(0), ZeroVal, TrueState, in performKernelMalloc()
1227 void MallocChecker::checkBasicAlloc(const CallEvent &Call, in checkBasicAlloc() argument
1230 State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State, in checkBasicAlloc()
1232 State = ProcessZeroAllocCheck(Call, 0, State); in checkBasicAlloc()
1236 void MallocChecker::checkKernelMalloc(const CallEvent &Call, in checkKernelMalloc() argument
1240 performKernelMalloc(Call, C, State); in checkKernelMalloc()
1244 State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State, in checkKernelMalloc()
1249 static bool isStandardRealloc(const CallEvent &Call) { in isStandardRealloc() argument
1250 const FunctionDecl *FD = dyn_cast<FunctionDecl>(Call.getDecl()); in isStandardRealloc()
1263 static bool isGRealloc(const CallEvent &Call) { in isGRealloc() argument
1264 const FunctionDecl *FD = dyn_cast<FunctionDecl>(Call.getDecl()); in isGRealloc()
1277 void MallocChecker::checkRealloc(const CallEvent &Call, CheckerContext &C, in checkRealloc() argument
1285 if (!isStandardRealloc(Call) && !isGRealloc(Call)) in checkRealloc()
1288 State = ReallocMemAux(C, Call, ShouldFreeOnFail, State, AF_Malloc); in checkRealloc()
1289 State = ProcessZeroAllocCheck(Call, 1, State); in checkRealloc()
1293 void MallocChecker::checkCalloc(const CallEvent &Call, in checkCalloc() argument
1296 State = CallocMem(C, Call, State); in checkCalloc()
1297 State = ProcessZeroAllocCheck(Call, 0, State); in checkCalloc()
1298 State = ProcessZeroAllocCheck(Call, 1, State); in checkCalloc()
1302 void MallocChecker::checkFree(const CallEvent &Call, CheckerContext &C) const { in checkFree() argument
1305 if (suppressDeallocationsInSuspiciousContexts(Call, C)) in checkFree()
1307 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkFree()
1312 void MallocChecker::checkAlloca(const CallEvent &Call, in checkAlloca() argument
1315 State = MallocMemAux(C, Call, Call.getArgExpr(0), UndefinedVal(), State, in checkAlloca()
1317 State = ProcessZeroAllocCheck(Call, 0, State); in checkAlloca()
1321 void MallocChecker::checkStrdup(const CallEvent &Call, in checkStrdup() argument
1324 const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); in checkStrdup()
1332 void MallocChecker::checkIfNameIndex(const CallEvent &Call, in checkIfNameIndex() argument
1338 MallocMemAux(C, Call, UnknownVal(), UnknownVal(), State, AF_IfNameIndex); in checkIfNameIndex()
1343 void MallocChecker::checkIfFreeNameIndex(const CallEvent &Call, in checkIfFreeNameIndex() argument
1347 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkIfFreeNameIndex()
1352 void MallocChecker::checkCXXNewOrCXXDelete(const CallEvent &Call, in checkCXXNewOrCXXDelete() argument
1356 const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); in checkCXXNewOrCXXDelete()
1360 assert(isStandardNewDelete(Call)); in checkCXXNewOrCXXDelete()
1370 MallocMemAux(C, Call, CE->getArg(0), UndefinedVal(), State, AF_CXXNew); in checkCXXNewOrCXXDelete()
1371 State = ProcessZeroAllocCheck(Call, 0, State); in checkCXXNewOrCXXDelete()
1374 State = MallocMemAux(C, Call, CE->getArg(0), UndefinedVal(), State, in checkCXXNewOrCXXDelete()
1376 State = ProcessZeroAllocCheck(Call, 0, State); in checkCXXNewOrCXXDelete()
1379 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkCXXNewOrCXXDelete()
1383 State = FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocatedMemory, in checkCXXNewOrCXXDelete()
1393 void MallocChecker::checkGMalloc0(const CallEvent &Call, in checkGMalloc0() argument
1398 State = MallocMemAux(C, Call, Call.getArgExpr(0), zeroVal, State, AF_Malloc); in checkGMalloc0()
1399 State = ProcessZeroAllocCheck(Call, 0, State); in checkGMalloc0()
1403 void MallocChecker::checkGMemdup(const CallEvent &Call, in checkGMemdup() argument
1407 MallocMemAux(C, Call, Call.getArgExpr(1), UnknownVal(), State, AF_Malloc); in checkGMemdup()
1408 State = ProcessZeroAllocCheck(Call, 1, State); in checkGMemdup()
1412 void MallocChecker::checkGMallocN(const CallEvent &Call, in checkGMallocN() argument
1416 SVal TotalSize = evalMulForBufferSize(C, Call.getArgExpr(0), Call.getArgExpr(1)); in checkGMallocN()
1417 State = MallocMemAux(C, Call, TotalSize, Init, State, AF_Malloc); in checkGMallocN()
1418 State = ProcessZeroAllocCheck(Call, 0, State); in checkGMallocN()
1419 State = ProcessZeroAllocCheck(Call, 1, State); in checkGMallocN()
1423 void MallocChecker::checkGMallocN0(const CallEvent &Call, in checkGMallocN0() argument
1428 SVal TotalSize = evalMulForBufferSize(C, Call.getArgExpr(0), Call.getArgExpr(1)); in checkGMallocN0()
1429 State = MallocMemAux(C, Call, TotalSize, Init, State, AF_Malloc); in checkGMallocN0()
1430 State = ProcessZeroAllocCheck(Call, 0, State); in checkGMallocN0()
1431 State = ProcessZeroAllocCheck(Call, 1, State); in checkGMallocN0()
1435 void MallocChecker::checkReallocN(const CallEvent &Call, in checkReallocN() argument
1438 State = ReallocMemAux(C, Call, /*ShouldFreeOnFail=*/false, State, AF_Malloc, in checkReallocN()
1440 State = ProcessZeroAllocCheck(Call, 1, State); in checkReallocN()
1441 State = ProcessZeroAllocCheck(Call, 2, State); in checkReallocN()
1445 void MallocChecker::checkOwnershipAttr(const CallEvent &Call, in checkOwnershipAttr() argument
1448 const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); in checkOwnershipAttr()
1462 State = MallocMemReturnsAttr(C, Call, I, State); in checkOwnershipAttr()
1466 State = FreeMemAttr(C, Call, I, State); in checkOwnershipAttr()
1474 void MallocChecker::checkPostCall(const CallEvent &Call, in checkPostCall() argument
1478 if (!Call.getOriginExpr()) in checkPostCall()
1483 if (const CheckFn *Callback = FreeingMemFnMap.lookup(Call)) { in checkPostCall()
1484 (*Callback)(this, Call, C); in checkPostCall()
1488 if (const CheckFn *Callback = AllocatingMemFnMap.lookup(Call)) { in checkPostCall()
1489 (*Callback)(this, Call, C); in checkPostCall()
1493 if (const CheckFn *Callback = ReallocatingMemFnMap.lookup(Call)) { in checkPostCall()
1494 (*Callback)(this, Call, C); in checkPostCall()
1498 if (isStandardNewDelete(Call)) { in checkPostCall()
1499 checkCXXNewOrCXXDelete(Call, C); in checkPostCall()
1503 checkOwnershipAttr(Call, C); in checkPostCall()
1508 const CallEvent &Call, const unsigned IndexOfSizeArg, ProgramStateRef State, in ProcessZeroAllocCheck() argument
1514 RetVal = Call.getReturnValue(); in ProcessZeroAllocCheck()
1518 if (const CallExpr *CE = dyn_cast<CallExpr>(Call.getOriginExpr())) { in ProcessZeroAllocCheck()
1521 dyn_cast<CXXNewExpr>(Call.getOriginExpr())) { in ProcessZeroAllocCheck()
1533 State->getSVal(Arg, Call.getLocationContext()).getAs<DefinedSVal>(); in ProcessZeroAllocCheck()
1612 MallocChecker::processNewAllocation(const CXXAllocatorCall &Call, in processNewAllocation() argument
1615 if (!isStandardNewDelete(Call)) in processNewAllocation()
1618 const CXXNewExpr *NE = Call.getOriginExpr(); in processNewAllocation()
1633 SVal Target = Call.getObjectUnderConstruction(); in processNewAllocation()
1635 State = ProcessZeroAllocCheck(Call, 0, State, Target); in processNewAllocation()
1639 void MallocChecker::checkNewAllocator(const CXXAllocatorCall &Call, in checkNewAllocator() argument
1643 Call, C, in checkNewAllocator()
1644 (Call.getOriginExpr()->isArray() ? AF_CXXNewArray : AF_CXXNew)); in checkNewAllocator()
1649 static bool isKnownDeallocObjCMethodName(const ObjCMethodCall &Call) { in isKnownDeallocObjCMethodName() argument
1655 StringRef FirstSlot = Call.getSelector().getNameForSlot(0); in isKnownDeallocObjCMethodName()
1661 static Optional<bool> getFreeWhenDoneArg(const ObjCMethodCall &Call) { in getFreeWhenDoneArg() argument
1662 Selector S = Call.getSelector(); in getFreeWhenDoneArg()
1667 return !Call.getArgSVal(i).isZeroConstant(); in getFreeWhenDoneArg()
1672 void MallocChecker::checkPostObjCMessage(const ObjCMethodCall &Call, in checkPostObjCMessage() argument
1677 if (!isKnownDeallocObjCMethodName(Call)) in checkPostObjCMessage()
1680 if (Optional<bool> FreeWhenDone = getFreeWhenDoneArg(Call)) in checkPostObjCMessage()
1684 if (Call.hasNonZeroCallbackArg()) in checkPostObjCMessage()
1689 FreeMemAux(C, Call.getArgExpr(0), Call, C.getState(), in checkPostObjCMessage()
1697 MallocChecker::MallocMemReturnsAttr(CheckerContext &C, const CallEvent &Call, in MallocMemReturnsAttr() argument
1708 return MallocMemAux(C, Call, Call.getArgExpr(I->getASTIndex()), in MallocMemReturnsAttr()
1711 return MallocMemAux(C, Call, UnknownVal(), UndefinedVal(), State, AF_Malloc); in MallocMemReturnsAttr()
1715 const CallEvent &Call, in MallocMemAux() argument
1723 return MallocMemAux(C, Call, C.getSVal(SizeEx), Init, State, Family); in MallocMemAux()
1727 const CallEvent &Call, SVal Size, in MallocMemAux() argument
1733 const Expr *CE = Call.getOriginExpr(); in MallocMemAux()
1784 const CallEvent &Call, in FreeMemAttr() argument
1797 FreeMemAux(C, Call, State, Arg.getASTIndex(), in FreeMemAttr()
1807 const CallEvent &Call, in FreeMemAux() argument
1815 if (Call.getNumArgs() < (Num + 1)) in FreeMemAux()
1818 return FreeMemAux(C, Call.getArgExpr(Num), Call, State, Hold, in FreeMemAux()
1902 CheckerContext &C, const Expr *ArgExpr, const CallEvent &Call, in FreeMemAux() argument
1930 const Expr *ParentExpr = Call.getOriginExpr(); in FreeMemAux()
2570 MallocChecker::ReallocMemAux(CheckerContext &C, const CallEvent &Call, in ReallocMemAux() argument
2576 const CallExpr *CE = cast<CallExpr>(Call.getOriginExpr()); in ReallocMemAux()
2623 C, Call, TotalSize, UndefinedVal(), StatePtrIsNull, Family); in ReallocMemAux()
2641 C, Call, StateSizeIsZero, 0, false, IsKnownToBeAllocated, Family)) in ReallocMemAux()
2646 FreeMemAux(C, Call, State, 0, false, IsKnownToBeAllocated, Family)) { in ReallocMemAux()
2649 MallocMemAux(C, Call, TotalSize, UnknownVal(), stateFree, Family); in ReallocMemAux()
2679 const CallEvent &Call, in CallocMem() argument
2684 if (Call.getNumArgs() < 2) in CallocMem()
2690 evalMulForBufferSize(C, Call.getArgExpr(0), Call.getArgExpr(1)); in CallocMem()
2692 return MallocMemAux(C, Call, TotalSize, zeroVal, State, AF_Malloc); in CallocMem()
2862 void MallocChecker::checkPreCall(const CallEvent &Call, in checkPreCall() argument
2865 if (const auto *DC = dyn_cast<CXXDeallocatorCall>(&Call)) { in checkPreCall()
2877 State = FreeMemAux(C, DE->getArgument(), Call, State, in checkPreCall()
2885 if (const auto *DC = dyn_cast<CXXDestructorCall>(&Call)) { in checkPreCall()
2892 if (const AnyFunctionCall *FC = dyn_cast<AnyFunctionCall>(&Call)) { in checkPreCall()
2897 if (ChecksEnabled[CK_MallocChecker] && isFreeingCall(Call)) in checkPreCall()
2902 if (const CXXInstanceCall *CC = dyn_cast<CXXInstanceCall>(&Call)) { in checkPreCall()
2909 for (unsigned I = 0, E = Call.getNumArgs(); I != E; ++I) { in checkPreCall()
2910 SVal ArgSVal = Call.getArgSVal(I); in checkPreCall()
2915 if (checkUseAfterFree(Sym, C, Call.getArgExpr(I))) in checkPreCall()
3007 const CallEvent &Call, CheckerContext &C) const { in suppressDeallocationsInSuspiciousContexts() argument
3008 if (Call.getNumArgs() == 0) in suppressDeallocationsInSuspiciousContexts()
3026 for (const Expr *Arg : cast<CallExpr>(Call.getOriginExpr())->arguments()) in suppressDeallocationsInSuspiciousContexts()
3125 const CallEvent *Call, in mayFreeAnyEscapedMemoryOrIsModeledExplicitly() argument
3128 assert(Call); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3135 if (!isa<SimpleFunctionCall, ObjCMethodCall>(Call)) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3139 if (const ObjCMethodCall *Msg = dyn_cast<ObjCMethodCall>(Call)) { in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3142 if (!Call->isInSystemHeader() || Call->argumentsMayEscape()) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3190 const FunctionDecl *FD = cast<SimpleFunctionCall>(Call)->getDecl(); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3196 if (isMemCall(*Call)) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3200 if (!Call->isInSystemHeader()) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3215 for (unsigned i = 1; i < Call->getNumArgs(); ++i) { in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3216 const Expr *ArgE = Call->getArgExpr(i)->IgnoreParenCasts(); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3231 if (Call->getNumArgs() >= 4 && Call->getArgSVal(4).isConstant(0)) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3239 if (Call->getNumArgs() >= 1) { in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3240 const Expr *ArgE = Call->getArgExpr(0)->IgnoreParenCasts(); in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3275 if (Call->argumentsMayEscape()) in mayFreeAnyEscapedMemoryOrIsModeledExplicitly()
3285 const CallEvent *Call, in checkPointerEscape() argument
3287 return checkPointerEscapeAux(State, Escaped, Call, Kind, in checkPointerEscape()
3293 const CallEvent *Call, in checkConstPointerEscape() argument
3296 return checkPointerEscapeAux(State, Escaped, Call, Kind, in checkConstPointerEscape()
3307 const CallEvent *Call, PointerEscapeKind Kind, in checkPointerEscapeAux() argument
3313 !mayFreeAnyEscapedMemoryOrIsModeledExplicitly(Call, State, in checkPointerEscapeAux()
3458 CallEventRef<> Call = CEMgr.getSimpleCall(CallE, state, CurrentLC); in VisitNode() local
3459 if (const auto *D = dyn_cast_or_null<NamedDecl>(Call->getDecl())) in VisitNode()