https://github.com/steakhal updated 
https://github.com/llvm/llvm-project/pull/91675

>From 846be0552bd2da608fc1729e5928d85650e1ce06 Mon Sep 17 00:00:00 2001
From: Andrew Sukach <andrewsuk...@gmail.com>
Date: Thu, 9 May 2024 18:49:41 -0400
Subject: [PATCH 1/2] [clang][static analyzer] ignore try statements in dead
 code checker

---
 .../Checkers/UnreachableCodeChecker.cpp              |  4 +++-
 clang/test/Analysis/unreachable-code-exceptions.cpp  | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Analysis/unreachable-code-exceptions.cpp

diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
index d24a124f5ffee..7ce9a5b5bb6dc 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<CXXTryStmt>(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 0000000000000..aad7625b92d71
--- /dev/null
+++ b/clang/test/Analysis/unreachable-code-exceptions.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -verify %s -fcxx-exceptions -fexceptions 
-analyzer-checker=core -analyzer-checker=alpha.deadcode.UnreachableCode
+
+// expected-no-diagnostics
+
+void foo();
+
+void f4() {
+  try {
+    foo();
+  } catch (int) {
+  }
+}
\ No newline at end of file

>From bfe9a244ed3e81669824f6d5a4e8b6ed9409375c Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbal...@gmail.com>
Date: Tue, 14 May 2024 08:55:29 +0200
Subject: [PATCH 2/2] Simplify RUN line.

---
 clang/test/Analysis/unreachable-code-exceptions.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Analysis/unreachable-code-exceptions.cpp 
b/clang/test/Analysis/unreachable-code-exceptions.cpp
index aad7625b92d71..68c32e8a6e400 100644
--- a/clang/test/Analysis/unreachable-code-exceptions.cpp
+++ b/clang/test/Analysis/unreachable-code-exceptions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -verify %s -fcxx-exceptions -fexceptions 
-analyzer-checker=core -analyzer-checker=alpha.deadcode.UnreachableCode
+// RUN: %clang_analyze_cc1 -verify %s -fcxx-exceptions -fexceptions 
-analyzer-checker=core,alpha.deadcode.UnreachableCode
 
 // expected-no-diagnostics
 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to