[clang] [LifetimeSafety] Fix handling of reference-type DeclRefExpr (PR #176728)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 19 03:20:15 PST 2026


================
@@ -589,9 +589,10 @@ void FactsGenerator::handleUse(const DeclRefExpr *DRE) {
   OriginList *List = getOriginsList(*DRE);
   if (!List)
     return;
-  // Remove the outer layer of origin which borrows from the decl directly. This
-  // is a use of the underlying decl.
-  List = getRValueOrigins(DRE, List);
+  // Remove the outer layer of origin which borrows from the decl directly
+  // (e.g., when this is not a reference). This is a use of the underlying decl.
+  if (!DRE->getDecl()->getType()->isReferenceType())
----------------
Xazax-hun wrote:

This change looks good to me. The only surprising part, which strictly speaking is not related to this PR, I wonder if `getRValueOrigins` is at the right place to begin with. I'd expect this to show up in a code path that handles the lvalue to rvalue conversion. 

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


More information about the cfe-commits mailing list