[PATCH] make analyzer track memory allocated by if_nameindex
Anna Zaks
ganna at apple.com
Wed Sep 24 10:02:14 PDT 2014
How about the similar functions from the malloc family: isAllocationFunction and isFreeFunction?
You could either introduce a helper function which checks if the FunctionDecl declares a function from the given list of identifiers or introduce a function that takes FunctionDecl, ASTContext, familyKind, and MemoryOperationKind (enum class MemoryOperationKind { MOK_Allocate, MOK_Free };) and checks if the FunctionDecl belongs to that family and memory operation. (The second approach is probably better.)
Cheers,
Anna.
> On Sep 24, 2014, at 3:06 AM, Daniel Fahlgren <daniel at fahlgren.se> wrote:
>
> Hi Anna,
>
> On Mon, 2014-09-22 at 22:54 -0700, Anna Zaks wrote:
>> The bodies of these functions look very similar. Please, try to factor
>> out the copy and paste.
>> +bool MallocChecker::isIfNameFunction(const FunctionDecl *FD,
>> +bool MallocChecker::isIfFreeNameFunction(const FunctionDecl *FD,
>> ASTContext &C) const {
>
>> Otherwise, looks good to me.
>
> Thanks for reviewing this. Attached is an updated patch where the two
> functions are refactored to a single one.
>
> Best regards,
> Daniel Fahlgren
> <ifnameindex.patch>
More information about the cfe-commits
mailing list