[clang] [analyzer] Model GCC 'cleanup' attribute function calls (PR #221110)
Arseniy Zaostrovnykh via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 02:55:29 PDT 2026
================
@@ -0,0 +1,27 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,cplusplus,security,deadcode,nullability,optin.portability,optin.performance,optin.core,debug.ExprInspection -verify %s
+
+// Run the cleanup function modeling with a broad set of checkers: the
+// CleanupFunctionCall has an argument without a source expression, which
+// must not crash checkers that inspect call arguments.
+
+#include "Inputs/system-header-simulator-for-malloc.h"
+
+void clang_analyzer_warnIfReached(void);
+
+void declared_only_cleanup(void *p);
+
+static void noop_cleanup(int *p) {
+ clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
----------------
necto wrote:
This might trigger also when `noop_cleanup` is picked as an entry point, not only when it is being triggered as a cleanup function. You can print the value of `p` to prove that it is invoked from `many_checkers_with_cleanup`
https://github.com/llvm/llvm-project/pull/221110
More information about the cfe-commits
mailing list