diff options
author | Daniel Marjamaki <daniel.marjamaki@evidente.se> | 2016-09-28 10:39:53 +0000 |
---|---|---|
committer | Daniel Marjamaki <daniel.marjamaki@evidente.se> | 2016-09-28 10:39:53 +0000 |
commit | 2593b402ced66c14e59f59fcbb2ce92a4e55a04d (patch) | |
tree | c9e7e6be9c957ed95fc3ecdf78f174ab1b0f05eb /clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp | |
parent | e6d01e08c6c1c156a42eecc84d268e93bbd53490 (diff) | |
download | bcm5719-llvm-2593b402ced66c14e59f59fcbb2ce92a4e55a04d.tar.gz bcm5719-llvm-2593b402ced66c14e59f59fcbb2ce92a4e55a04d.zip |
[StaticAnalyzer] Fix false positives for vardecls that are technically unreachable but they are needed.
Example:
switch (x) {
int a; // <- This is unreachable but needed
case 1:
a = ...
Differential Revision: https://reviews.llvm.org/D24905
llvm-svn: 282574
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index 892e713d241..ff07a64d9b1 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -191,8 +191,10 @@ void UnreachableCodeChecker::FindUnreachableEntryPoints(const CFGBlock *CB, // Find the Stmt* in a CFGBlock for reporting a warning const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) { for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) { - if (Optional<CFGStmt> S = I->getAs<CFGStmt>()) - return S->getStmt(); + if (Optional<CFGStmt> S = I->getAs<CFGStmt>()) { + if (!isa<DeclStmt>(S->getStmt())) + return S->getStmt(); + } } if (const Stmt *S = CB->getTerminator()) return S; |