================
@@ -663,6 +672,22 @@ class MallocChecker
SVal Init, ProgramStateRef State,
AllocationFamily Family) const;
+ /// Models a non-successful memory allocation.
+ /// Can be used if the allocation function may return null on failure when
the
+ /// size to be allocated is non-zero.
+ ///
+ /// \param [in] Call The expression that allocates memory.
+ /// \param [in] SizeArgI1 Index of the argument that specifies the allocation
+ /// size or count. -1 if not applicable.
+ /// \param [in] SizeArgI2 Index of another argument that specifies allocation
+ /// size (i. e. "element size"). -1 if not applicable.
+ /// \param [in] State The \c ProgramState right before allocation.
+ /// \returns The ProgramState right after an unsuccessful allocation.
+ [[nodiscard]] ProgramStateRef FailedAlloc(CheckerContext &C,
+ const CallEvent &Call,
+ int SizeArgI1, int SizeArgI2,
+ ProgramStateRef State) const;
----------------
steakhal wrote:
I was reading this PR again, and I think we could make it better.
How about moving the SizeArgs after State?
Then we could pass an `llvm::ArrayRef<unsigned> SizeArgIndexes= {}`
Then at the callsites, you could leave it empty if none should be passed.
Otherwise pass `{1}` or whatever.
WDYT? @balazske
https://github.com/llvm/llvm-project/pull/205371
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits