llvm-project
4a0f2d49 - [analyzer] Put PostVisit after EagerlyAssume (#239123)

Commit
21 hours ago
[analyzer] Put PostVisit after EagerlyAssume (#239123) In general, `PostVisit` is the last thing we do with a statement; `EagerlyAssume` has no good reason to run after it. After this `PostStmt<UnaryOperator>` and `PostStmt<BinaryOperator>` callbacks will be able to see the effects of `EagerlyAssume`, which should be more useful than the status quo. There were only three checkers with `PostStmt` callbacks for unary or binary operators: - `ArrayBoundChecker.cpp` is unaffected, its `UnaryOperator` callback only cares for `UO_Deref` and ignores `UO_LNot`. - In `IteratorModeling.cpp` the `UnaryOperator` callback is unaffected (only cares for increment and decrement), and the `BinaryOperator` callback is perturbed, but it is prepared to see either concrete or symbolic results from the equality checks, so should be fine. - In `UndefResultChecker` the `BinaryOperator` callback is uanffected because it only cares for operator expressions with Undefined result, and those are not affected by the EagerlyAssume logic. EagerlyAssume had a defensive check for the presence of a `PostStmt` node for the same expression, but evaluation of logical negation or comparison operators always creates a `PostStmt` node (which before this commit could be followed by `PostStmt` nodes added by checkers), so I think this defensive check was never relevant. (I'll try to remove it in a follow-up commit.) After this the Pre/Post visit of unary operators can be handled in a regular way, but I'm postponing that for a follow-up change, because it will let us unindent the whole body of `VisitUnaryOperator`, and I don't want to touch so many lines in a non-NFC commit. Pre/Post visit of binary operators is still irregular after this because logical operators are not Pre/Post visited at all.
Author
Parents
Loading