[clang] [LifetimeSafety] Implement multi-level origins (PR #168344)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 8 06:56:26 PST 2025
================
@@ -237,13 +348,25 @@ void FactsGenerator::handleGSLPointerConstruction(const CXXConstructExpr *CCE) {
assert(isGslPointerType(CCE->getType()));
if (CCE->getNumArgs() != 1)
return;
- if (hasOrigin(CCE->getArg(0)))
- killAndFlowOrigin(*CCE, *CCE->getArg(0));
- else
+
+ const Expr *Arg = CCE->getArg(0);
+ if (isGslPointerType(Arg->getType())) {
+ OriginList *ArgList = getOriginsList(*Arg);
+ assert(ArgList && "GSL pointer argument should have an origin list");
+ // GSL pointer is constructed from another gsl pointer.
+ // Example:
+ // View(View v);
+ // View(const View &v);
+ if (Arg->isGLValue())
----------------
usx95 wrote:
Hmm. This indeed looks like a pattern of forcing an `LValueToRValue` conversion.
https://github.com/llvm/llvm-project/pull/168344
More information about the cfe-commits
mailing list