[clang] [analyzer] Implemented the DanglingPtrDeref checker to detect use-after-scope lifetime errors (PR #206460)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 12 07:11:22 PDT 2026


================
@@ -0,0 +1,96 @@
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Checkers/LifetimeModeling.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class ReportDanglingPtrDeref : public Checker<check::Location> {
+public:
+  class ReportDanglingPtrDerefBRVisitor : public BugReporterVisitor {
----------------
steakhal wrote:

In LLVM, we usually hoist nested class declarations. Nesting them makes it more difficult to read.

https://github.com/llvm/llvm-project/pull/206460


More information about the cfe-commits mailing list