[clang] [clang][analyzer] Add allocation failure modeling to DynamicMemoryModeling (PR #205371)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 30 08:27:18 PDT 2026
================
@@ -2048,6 +2091,27 @@ ProgramStateRef MallocChecker::MallocMemAux(CheckerContext &C,
return MallocUpdateRefState(C, CE, State, Family);
}
+ProgramStateRef
+MallocChecker::FailedAlloc(CheckerContext &C, const CallEvent &Call,
+ ProgramStateRef State,
+ llvm::ArrayRef<unsigned> SizeArgIndexes) const {
+ if (!State || !ModelAllocationFailure)
+ return nullptr;
+
+ for (unsigned SizeArgI : SizeArgIndexes) {
+ auto DefArgVal = Call.getArgSVal(SizeArgI).getAs<DefinedOrUnknownSVal>();
----------------
balazske wrote:
There was no out of bounds check before this change either. Probably it is not that important because the function should be matched by `CallDescription` with correct argument count, there is no such check in other functions like `ProcessZeroAllocCheck`.
https://github.com/llvm/llvm-project/pull/205371
More information about the cfe-commits
mailing list