================
@@ -472,8 +489,19 @@ void FactsGenerator::VisitBinaryOperator(const
BinaryOperator *BO) {
killAndFlowOrigin(*BO, *BO->getRHS());
return;
}
- if (BO->isCompoundAssignmentOp())
+ if (BO->isCompoundAssignmentOp()) {
+ // A pointer compound additive assignment (`p += n`) keeps the pointer in
+ // the same allocation, so its result carries the LHS pointer's loans. The
+ // LHS is always an lvalue; peel when the result is a prvalue (in C).
+ if (BO->getType()->isPointerType()) {
+ OriginList *LHSList = getOriginsList(*BO->getLHS());
+ OriginList *Src = LHSList && !BO->isGLValue() ?
LHSList->peelOuterOrigin()
+ : LHSList;
----------------
NeKon69 wrote:
Same question here.
https://github.com/llvm/llvm-project/pull/204477
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits