================
@@ -314,39 +474,34 @@ bool FactsGenerator::handleTestPoint(const
CXXFunctionalCastExpr *FCE) {
return false;
}
-void FactsGenerator::handleAssignment(const Expr *LHSExpr,
- const Expr *RHSExpr) {
- if (!hasOrigin(LHSExpr))
- return;
- // Find the underlying variable declaration for the left-hand side.
- if (const auto *DRE_LHS =
- dyn_cast<DeclRefExpr>(LHSExpr->IgnoreParenImpCasts())) {
- markUseAsWrite(DRE_LHS);
- if (const auto *VD_LHS = dyn_cast<ValueDecl>(DRE_LHS->getDecl())) {
- // Kill the old loans of the destination origin and flow the new loans
- // from the source origin.
- killAndFlowOrigin(*VD_LHS, *RHSExpr);
- }
- }
-}
-
// A DeclRefExpr will be treated as a use of the referenced decl. It will be
// checked for use-after-free unless it is later marked as being written to
// (e.g. on the left-hand side of an assignment).
void FactsGenerator::handleUse(const DeclRefExpr *DRE) {
- if (isPointerType(DRE->getType())) {
- UseFact *UF = FactMgr.createFact<UseFact>(DRE, FactMgr.getOriginMgr());
- CurrentBlockFacts.push_back(UF);
- assert(!UseFacts.contains(DRE));
- UseFacts[DRE] = UF;
+ OriginList *List = getOriginsList(*DRE);
+ if (!List)
+ return;
+ // Remove the outer layer of origin which borrows from the decl directly.
This
+ // is a use of the underlying decl.
+ List = getRValueOrigins(DRE, List);
+ // Skip if there is no inner origin (e.g., when it is not a pointer type).
+ if (!List)
+ return;
+ llvm::SmallVector<OriginID> UsedOrigins;
+ OriginList *L = List;
+ while (L) {
+ UsedOrigins.push_back(L->getOuterOriginID());
+ L = L->peelOuterOrigin();
}
+ UseFact *UF = FactMgr.createFact<UseFact>(DRE, std::move(UsedOrigins));
----------------
usx95 wrote:
Done.
https://github.com/llvm/llvm-project/pull/168344
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits