[clang] [LifetimeSafety] Model pointer-to-data-member access in the fact generator (PR #204612)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 19 19:54:22 PDT 2026
================
@@ -468,6 +468,20 @@ void FactsGenerator::handlePointerArithmetic(const BinaryOperator *BO) {
}
void FactsGenerator::VisitBinaryOperator(const BinaryOperator *BO) {
+ if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI) {
+ // `obj.*pm` / `objptr->*pm` names a member of the object, so a borrow of it
+ // borrows the object; flow the object's origin into the result. For `.*`
+ // the object is the LHS; for `->*` it is the LHS pointer's pointee.
+ OriginList *Dst = getOriginsList(*BO);
+ OriginList *ObjSrc =
+ BO->getOpcode() == BO_PtrMemD
+ ? getOriginsList(*BO->getLHS())
+ : getRValueOrigins(BO->getLHS(), getOriginsList(*BO->getLHS()));
+ if (Dst && ObjSrc && Dst->getLength() == ObjSrc->getLength())
----------------
NeKon69 wrote:
I am a bit unsure about this check, is it actually needed? When will the mismatch happen?
https://github.com/llvm/llvm-project/pull/204612
More information about the cfe-commits
mailing list