diff options
| author | Anna Zaks <ganna@apple.com> | 2013-09-17 00:53:28 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2013-09-17 00:53:28 +0000 |
| commit | fb05094b526217ff2c7702d9236d69a3fbe268fc (patch) | |
| tree | 961a93ec4a2e656bb033b6253b4170166e4e24cb /clang/lib/StaticAnalyzer | |
| parent | 9fc443aaedafb512108bd2ef3f48df570efee3b3 (diff) | |
| download | bcm5719-llvm-fb05094b526217ff2c7702d9236d69a3fbe268fc.tar.gz bcm5719-llvm-fb05094b526217ff2c7702d9236d69a3fbe268fc.zip | |
[analyzer] Stop tracking the objects with attribute cleanup in the RetainCountChecker.
This suppresses false positive leaks. We stop tracking a value if it is assigned to a variable declared with a cleanup attribute.
llvm-svn: 190835
Diffstat (limited to 'clang/lib/StaticAnalyzer')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 7a97ce52c68..d2a4448a5fd 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -3356,6 +3356,16 @@ void RetainCountChecker::checkBind(SVal loc, SVal val, const Stmt *S, } } + // If we are storing the value into an auto function scope variable annotated + // with (__attribute__((cleanup))), stop tracking the value to avoid leak + // false positives. + if (const VarRegion *LVR = dyn_cast_or_null<VarRegion>(loc.getAsRegion())) { + const VarDecl *VD = LVR->getDecl(); + if (VD->getAttr<CleanupAttr>()) { + escapes = true; + } + } + // If our store can represent the binding and we aren't storing to something // that doesn't have local storage then just return and have the simulation // state continue as is. |

