[clang] [LifetimeSafety][NFC] Refactor OriginList to OriginNode tree (PR #194797)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 06:33:54 PDT 2026


================
@@ -92,30 +92,42 @@ struct Origin {
 ///
 /// The list structure enables the analysis to track how loans flow through
 /// different levels of indirection when assignments and dereferences occur.
-class OriginList {
+///
+/// TODO: Currently list-shaped (each node has at most one pointee child).
+/// Will become tree-shaped once field children are added to support
+/// origin trees for records whose fields have origins.
+class OriginNode {
 public:
-  OriginList(OriginID OID) : OuterOID(OID) {}
+  OriginNode(OriginID OID) : OID(OID) {}
 
-  OriginList *peelOuterOrigin() const { return InnerList; }
-  OriginID getOuterOriginID() const { return OuterOID; }
+  OriginNode *getPointeeChild() const {
+    return NumChildren ? Children[0] : nullptr;
+  }
 
-  void setInnerOriginList(OriginList *Inner) { InnerList = Inner; }
+  OriginID getOriginID() const { return OID; }
 
-  // Used for assertion checks only (to ensure origin lists have matching
+  void setChildren(OriginNode **Arr, unsigned N) {
----------------
Xazax-hun wrote:

I wonder if it would be better to take an `llvm::ArrayRef` or something similar. 

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


More information about the cfe-commits mailing list