================
@@ -472,8 +487,18 @@ 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. In C
+ // the result is a prvalue, so peel the LHS's storage origin.
+ if (BO->getType()->isPointerType()) {
+ OriginList *LHSList = getOriginsList(*BO->getLHS());
+ flow(getOriginsList(*BO),
+ IsCMode ? getRValueOrigins(BO->getLHS(), LHSList) : LHSList,
----------------
NeKon69 wrote:
Since in C it's always a glvalue:
```suggestion
IsCMode ? LHSList->peelOuterOrigin() : LHSList,
```
https://github.com/llvm/llvm-project/pull/204477
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits