================ @@ -154,12 +154,14 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator *B, auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg_MemRegionDifferent, N); R->addRange(B->getSourceRange()); - if (DiffDeclL) - R->addNote("Array at the left-hand side of subtraction", - {DiffDeclL, C.getSourceManager()}); - if (DiffDeclR) - R->addNote("Array at the right-hand side of subtraction", - {DiffDeclR, C.getSourceManager()}); + if (DiffDeclL != DiffDeclR) { ---------------- NagyDonat wrote:
```suggestion if (DiffDeclL != DiffDeclR) { // The declarations may be identical even if the regions are different, // if they are field regions within different objects: // struct { int array[10]; } a, b; // do_something_with(a.array[5] - b.array[5]); // In this case the notes would be confusing, so don't emit them. ``` Add a comment that explains this `if (DiffDeclL != DiffDeclR)` check because otherwise it would be very surprising. https://github.com/llvm/llvm-project/pull/95899 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits