[clang] [analyzer] Implemented the DanglingPtrDeref checker to detect use-after-scope lifetime errors (PR #209278)
Benedek Kaibas via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 14 03:49:07 PDT 2026
================
@@ -0,0 +1,86 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.ReportDanglingPtrDeref \
+// RUN: -analyzer-config cfg-lifetime=true -analyzer-output=text -verify %s
+
+void test_case_one() {
+ int *ptr = nullptr;
+ // expected-note at +1 {{'num' is destroyed here}}
----------------
benedekaibas wrote:
Yes, they were. I have looked at @steakhal's patch and switched to the `createEnd` function to correctly point to the closing brace. Also checked the implementation of `createEnd` to make sure it is the correct one.
https://github.com/llvm/llvm-project/blob/7de5af16e0e72d6325d3dd63ee619a1cb3bce783/clang/include/clang/Analysis/PathDiagnostic.h#L272-L276
https://github.com/llvm/llvm-project/pull/209278
More information about the cfe-commits
mailing list