================
@@ -378,11 +371,22 @@ void FactsGenerator::handleAssignment(const Expr *LHSExpr,
flow(LHSList->peelOuterOrigin(), RHSList, /*Kill=*/true);
}
+void FactsGenerator::handlePointerArithmetic(const BinaryOperator *BO) {
+ if (Expr *RHS = BO->getRHS(); RHS->getType()->isPointerType()) {
+ flowOrigin(*BO, *RHS);
+ return;
+ }
+ Expr *LHS = BO->getLHS();
+ assert(LHS->getType()->isPointerType() &&
+ "Pointer arithmetic must have a pointer operand");
+ flowOrigin(*BO, *LHS);
+}
+
void FactsGenerator::VisitBinaryOperator(const BinaryOperator *BO) {
- // TODO: Handle pointer arithmetic (e.g., `p + 1` or `1 + p`) where the
- // result should have the same loans as the pointer operand.
if (BO->isCompoundAssignmentOp())
return;
+ if (BO->getType()->isPointerType() && BO->isAdditiveOp())
----------------
Xazax-hun wrote:
Does this handle pointer arithmetic like `p - 5`?
https://github.com/llvm/llvm-project/pull/189546
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits