r178814 - [analyzer] Reduced the unwanted correlations between checkers living inside MallocChecker.cpp

Anton Yartsev anton.yartsev at gmail.com
Thu Apr 4 17:33:22 PDT 2013


On 05.04.2013 3:52, Jordan Rose wrote:
>
> On Apr 4, 2013, at 16:46 , Anton Yartsev <anton.yartsev at gmail.com 
> <mailto:anton.yartsev at gmail.com>> wrote:
>
>> +  if (Family == AF_Malloc &&
>> +    (!Filter.CMallocOptimistic && !Filter.CMallocPessimistic))
>> +    return false;
>> +
>> +  if ((Family == AF_CXXNew || Family == AF_CXXNewArray) &&
>> +    !Filter.CNewDeleteChecker)
>> +    return false;
>> +
>> +  return true;
>> +}
>> +
>> +bool MallocChecker::isTrackedFamily(CheckerContext &C,
>> +                                    const Stmt *AllocDeallocStmt) 
>> const {
>> +  return isTrackedFamily(getAllocationFamily(C, AllocDeallocStmt));
>> +}
>> +
>> +bool MallocChecker::isTrackedFamily(CheckerContext &C, SymbolRef 
>> Sym) const {
>> +  const RefState *RS = C.getState()->get<RegionState>(Sym);
>> +
>> +  return RS ? isTrackedFamily(RS->getAllocationFamily())
>> +            : isTrackedFamily(AF_None);
>> +}
>
> Uh, this is not correct; this will say that AF_None is a tracked 
> family, which means any symbol with no RefState has a tracked family.
This is made for cases:

int i;
free(&i);

and similar.
We may add something like assert(family != AF_None) somewhere else if 
AF_None is not acceptable. How do you think?

>
> A (fully-covered) switch statement might also be safer than the series 
> of ifs, because then we won't forget to update it later.
Committed at r178820.
>
> Jordan
>
-- 
Anton

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130405/148df2ba/attachment.html>


More information about the cfe-commits mailing list