[clang] [LifetimeSafety] Model an explicit `a.operator=(b)` call as an assignment (PR #244607)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 23 04:46:23 PST 2026
================
@@ -596,34 +603,31 @@ void FactsGenerator::VisitAbstractConditionalOperator(
FBPred);
}
+bool FactsGenerator::handleAssignmentOperatorCall(const CallExpr *CE,
+ const Expr *LHSExpr,
+ const Expr *RHSExpr) {
+ QualType LHSTy = LHSExpr->getType();
+ if (!hasOrigins(LHSTy))
+ return false;
+ const auto *RD = LHSTy->getAsCXXRecordDecl();
+ const auto *MD = dyn_cast_or_null<CXXMethodDecl>(CE->getDirectCallee());
+ // Pointer-like types and standard library callable wrappers (e.g.,
+ // std::function) propagate origins. Other tracked types only do so through
+ // a defaulted operator=; user-defined ones have opaque semantics.
+ if (!LHSTy->isPointerOrReferenceType() && !isGslPointerType(LHSTy) &&
+ !isGslOwnerType(LHSTy) && !(RD && isStdCallableWrapperType(RD)) &&
+ !(MD && MD->isDefaulted()))
----------------
usx95 wrote:
+1. I would suggest to split the condition and repeat the handleAssignment call with original non-negated conditions with separate comments.
https://github.com/llvm/llvm-project/pull/244607
More information about the cfe-commits
mailing list