================
@@ -438,12 +452,31 @@ class FactGenerator : public
ConstStmtVisitor<FactGenerator> {
void VisitDeclStmt(const DeclStmt *DS) {
for (const Decl *D : DS->decls())
if (const auto *VD = dyn_cast<VarDecl>(D))
- if (hasOrigin(VD->getType()))
+ if (hasOrigin(VD))
if (const Expr *InitExpr = VD->getInit())
addAssignOriginFact(*VD, *InitExpr);
}
- void VisitDeclRefExpr(const DeclRefExpr *DRE) { handleUse(DRE); }
+ void VisitDeclRefExpr(const DeclRefExpr *DRE) {
+ handleUse(DRE);
+ // For non-pointer/non-view types, a reference to the variable's storage
+ // is a borrow. We create a loan for it.
+ // For pointer/view types, we stick to the existing model for now and do
+ // not create an extra origin for the l-value expression itself.
+
+ // FIXME: A loan to `DeclRefExpr` for a pointer or view type can be
----------------
usx95 wrote:
Yes.
This is to not create loans to pointer types/view types which will need
multi-origin modelling.
```
std::string_view s;
std::string_view t = s; // RHS is essentially a reference to view needing two
origins (Only the inner origin makes it to the LHS t)
```
https://github.com/llvm/llvm-project/pull/156896
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits