[clang] [analyzer] Skip LifetimeEnd nodes in getNextStmtForDiagnostics (PR #228045)
Benedek Kaibas via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 2 01:30:08 PDT 2026
================
@@ -0,0 +1,51 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection,alpha.core.DanglingPtrDeref -analyzer-config cfg-lifetime=true -analyzer-output=text -verify %s
+
+void clang_analyzer_warnIfReached();
+
+// Enabling CFG lifetime-end elements should not cause regression in the
+// path notes. The loop exit path note must point to the next executed
+// statmeent and not back to the loop.
+void testPathNotesWithLoopScopeEnd() {
+ int *p = nullptr;
+ for (int i = 0; i < 3; ++i) {
+ // expected-note at -1 3 {{Loop condition is true. Entering loop body}}
----------------
benedekaibas wrote:
Yes, we do:
```cpp
C.getActivePath().push_front(
std::make_shared<PathDiagnosticControlFlowPiece>(
start, End, "Loop condition is true. Entering loop body"));
```
I will address this in a follow up.
https://github.com/llvm/llvm-project/pull/228045
More information about the cfe-commits
mailing list