[clang] [LifetimeSafety] Implement multi-level origins (PR #168344)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 2 09:39:23 PST 2025
================
@@ -237,13 +357,24 @@ 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
+
+ if (isGslPointerType(CCE->getArg(0)->getType())) {
+ OriginTree *ArgTree = getTree(*CCE->getArg(0));
+ assert(ArgTree && "GSL pointer argument should have an origin tree");
+ // GSL pointer is constructed from another gsl pointer.
+ // Example:
+ // View(View v);
+ // View(const View &v);
+ if (ArgTree->getDepth() == 2)
----------------
usx95 wrote:
Makes sense. Changed to
```
if (Arg->isGLValue())
```
https://github.com/llvm/llvm-project/pull/168344
More information about the cfe-commits
mailing list