[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:32 PST 2025
================
@@ -64,29 +93,48 @@ void FactsGenerator::run() {
void FactsGenerator::VisitDeclStmt(const DeclStmt *DS) {
for (const Decl *D : DS->decls())
if (const auto *VD = dyn_cast<VarDecl>(D))
- if (hasOrigin(VD))
- if (const Expr *InitExpr = VD->getInit())
- killAndFlowOrigin(*VD, *InitExpr);
+ if (const Expr *InitExpr = VD->getInit()) {
+ OriginTree *VDTree = getTree(*VD);
+ if (!VDTree)
+ continue;
+ OriginTree *InitTree = getTree(*InitExpr);
+ assert(InitTree && "VarDecl had origins but InitExpr did not");
+ // Special handling for rvalue references initialized with xvalues.
----------------
Xazax-hun wrote:
What about regular (non-rvalue) references? I am not sure I understand why is this case more special than that.
https://github.com/llvm/llvm-project/pull/168344
More information about the cfe-commits
mailing list