[clang] [LifetimeSafety] Implement multi-level origins (PR #168344)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 28 04:47:34 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)
----------------
Xazax-hun wrote:
I am not sure if having a hard-coded depth here is a good idea. Would this work with nested views?
https://github.com/llvm/llvm-project/pull/168344
More information about the cfe-commits
mailing list