diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2017-01-25 10:21:45 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2017-01-25 10:21:45 +0000 |
commit | 55705955ce89f9bec71c546d00e05b9b3d721e0c (patch) | |
tree | 127a9dfd04b31fd62d8d5113197b602512a7ac72 /clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp | |
parent | d28ab559a7e4c60bb56e5944bffe5085b7b16072 (diff) | |
download | bcm5719-llvm-55705955ce89f9bec71c546d00e05b9b3d721e0c.tar.gz bcm5719-llvm-55705955ce89f9bec71c546d00e05b9b3d721e0c.zip |
[analyzer] Fix MacOSXAPIChecker fp with static locals seen from nested blocks.
This is an attempt to avoid new false positives caused by the reverted r292800,
however the scope of the fix is significantly reduced - some variables are still
in incorrect memory spaces.
Relevant test cases added.
rdar://problem/30105546
rdar://problem/30156693
Differential revision: https://reviews.llvm.org/D28946
llvm-svn: 293043
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp index 0e0f52af316..437378e53da 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp @@ -94,11 +94,18 @@ void MacOSXAPIChecker::CheckDispatchOnce(CheckerContext &C, const CallExpr *CE, bool SuggestStatic = false; os << "Call to '" << FName << "' uses"; if (const VarRegion *VR = dyn_cast<VarRegion>(RB)) { + const VarDecl *VD = VR->getDecl(); + // FIXME: These should have correct memory space and thus should be filtered + // out earlier. This branch only fires when we're looking from a block, + // which we analyze as a top-level declaration, onto a static local + // in a function that contains the block. + if (VD->isStaticLocal()) + return; // We filtered out globals earlier, so it must be a local variable // or a block variable which is under UnknownSpaceRegion. if (VR != R) os << " memory within"; - if (VR->getDecl()->hasAttr<BlocksAttr>()) + if (VD->hasAttr<BlocksAttr>()) os << " the block variable '"; else os << " the local variable '"; |