diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index d24a124f5ffee0..7ce9a5b5bb6dcb 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -159,6 +159,8 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, SL = DL.asLocation(); if (SR.isInvalid() || !SL.isValid()) continue; + if (isa(S)) + continue; } else continue; @@ -254,4 +256,4 @@ void ento::registerUnreachableCodeChecker(CheckerManager &mgr) { bool ento::shouldRegisterUnreachableCodeChecker(const CheckerManager &mgr) { return true; -} +} \ No newline at end of file diff --git a/clang/test/Analysis/unreachable-code-exceptions.cpp b/clang/test/Analysis/unreachable-code-exceptions.cpp new file mode 100644 index 00000000000000..f47674ea8097de --- /dev/null +++ b/clang/test/Analysis/unreachable-code-exceptions.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_analyze_cc1 -verify %s -fcxx-exceptions -fexceptions -analyzer-checker=core,alpha.deadcode.UnreachableCode + +// expected-no-diagnostics + +void foo(); + +void fp_90162() { + try { // no-warning: The TryStmt shouldn't be unreachable. + foo(); + } catch (int) { + foo(); // We assume that catch handlers are reachable. + } +}