r179219 - [analyzer] Cleanup leak warnings: do not print the names of variables from other functions.

Jordan Rose jordan_rose at apple.com
Wed Apr 10 14:50:38 PDT 2013


On Apr 10, 2013, at 14:42 , Anna Zaks <ganna at apple.com> wrote:

> Author: zaks
> Date: Wed Apr 10 16:42:02 2013
> New Revision: 179219
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=179219&view=rev
> Log:
> [analyzer] Cleanup leak warnings: do not print the names of variables from other functions.
> 
> Modified:
>    cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
>    cfe/trunk/test/Analysis/malloc-plist.c
>    cfe/trunk/test/Analysis/retain-release.m
> 
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=179219&r1=179218&r2=179219&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Wed Apr 10 16:42:02 2013
> @@ -1527,13 +1527,19 @@ MallocChecker::getAllocationSite(const E
> 
>     // Find the most recent expression bound to the symbol in the current
>     // context.
> -    if (!ReferenceRegion) {
> -      if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
> -        SVal Val = State->getSVal(MR);
> -        if (Val.getAsLocSymbol() == Sym)
> -          ReferenceRegion = MR;
> +      if (!ReferenceRegion) {
> +        if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
> +          SVal Val = State->getSVal(MR);
> +          if (Val.getAsLocSymbol() == Sym) {
> +            const VarRegion* VR = MR->getAs<VarRegion>();
> +            // Do not show local variables belonging to a function other than
> +            // where the error is reported.
> +            if (!VR ||
> +                (VR->getStackFrame() == LeakContext->getCurrentStackFrame()))
> +              ReferenceRegion = MR;

This probably isn't good enough; consider storing into a field of a local variable in the wrong stack frame. Maybe use MR->getBaseRegion()?

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


More information about the cfe-commits mailing list