[clang] [LifetimeSafety] Detect use of a reference type as a use of underlying origin (PR #184295)

Zhijie Wang via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 29 21:43:47 PDT 2026


================
@@ -248,7 +249,9 @@ class UseFact : public Fact {
   const OriginList *getUsedOrigins() const { return OList; }
   const Expr *getUseExpr() const { return UseExpr; }
   void markAsWritten() { IsWritten = true; }
+  void markAsReferenceWrite() { IsReferenceWrite = true; }
----------------
aeft wrote:

Two approaches for the single-origin Read fact:
 
1. `std::variant<const OriginList *, OriginID>` in `UseFact`. `getUsedOrigins()` would be replaced by `forEachOrigin(Fn)` which abstracts over the variant internally.
2. Detached single-node `OriginList` via a new method `OriginManager::createSingleNode(OriginID)`. `UseFact` unchanged, just add a setter.
 
Both generate the same two UseFacts in `handleAssignment`. I'm leaning toward (2). Which do you prefer?

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


More information about the cfe-commits mailing list