[clang] [clang] Trigger checkLifetimeEnd callback from CFGLifetimeEnds element (PR #201123)

Arseniy Zaostrovnykh via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 2 08:51:47 PDT 2026


================
@@ -290,18 +293,38 @@ class CFGLoopExit : public CFGElement {
   }
 };
 
+/// Base class for representing elements related to the lifetime of automatic
+/// objects.
+class CFGScopeMarker : public CFGElement {
+public:
+  LLVM_ATTRIBUTE_RETURNS_NONNULL const Stmt *getTriggerStmt() const {
+    return static_cast<const Stmt *>(Data1.getPointer());
+  }
+
+private:
+  friend class CFGElement;
+
+  static bool isKind(const CFGElement &E) {
+    return E.getKind() >= SCOPE_BEGIN && E.getKind() <= SCOPE_END;
+  }
+
+protected:
+  CFGScopeMarker() = default;
+
+  explicit CFGScopeMarker(Kind K, const Stmt *S, const void *Ptr2 = nullptr)
+      : CFGElement(K, S, Ptr2) {
+    assert(isKind(*this));
+  }
+};
+
 /// Represents the point where the lifetime of an automatic object ends
-class CFGLifetimeEnds : public CFGElement {
+class CFGLifetimeEnds : public CFGScopeMarker {
 public:
   explicit CFGLifetimeEnds(const VarDecl *var, const Stmt *stmt)
----------------
necto wrote:

2788acdd8cd8 * [NFC] Capitalize params

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


More information about the cfe-commits mailing list