vsavchenko marked 3 inline comments as done. vsavchenko added a comment. Hi @ASDenysPetrov no problem at all! Thanks for taking your time and checking it.
================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:367-378 +RangeSet RangeSet::Delete(BasicValueFactory &BV, Factory &F, + const llvm::APSInt &Point) const { + llvm::APSInt Upper = Point; + llvm::APSInt Lower = Point; + + ++Upper; + --Lower; ---------------- ASDenysPetrov wrote: > Useful function. But I'd better rename it to `subtract` as we are working > with sets (as a mathimatical collection). We should have a such one for the > Ranges not only for Points. > We have `intersect`, `delete` aka `subtract`. And we also need to have > functions `union` and `symmetricDifference` to cover full palette of common > operations on sets. I agree that we should have a full set of functions. I don't agree however, that this function is a `subtract`. Subtract is an operation on two sets and here we have a set and a point. One might argue that a point is just a very simple set, that's true, but real `subtract` would be more complex in its implementation. Naming it `delete`, on the other hand, I was coming from a notion of deleting points or neighbourhoods (https://en.wikipedia.org/wiki/Neighbourhood_(mathematics)#Deleted_neighbourhood). ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734 // expressions which we currently do not know how to negate. - const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym) { + Optional<RangeSet> getRangeForInvertedSub(SymbolRef Sym) { if (const SymSymExpr *SSE = dyn_cast<SymSymExpr>(Sym)) { ---------------- ASDenysPetrov wrote: > As for me, I'd call this like `getRangeForNegatedSymSymExpr`, since you do > Negate operation inside. I'm not super happy about my name either, but I feel like it describes it better than the previous name and your version. That function doesn't work for any `SymSymExpr` and it doesn't simply negate whatever we gave it. It works specifically for symbolic subtractions and this is the information I want to be reflected in the name. ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:841-844 + RangeSet getTrueRange(QualType T) { + RangeSet TypeRange = infer(T); + return assumeNonZero(TypeRange, T); + } ---------------- ASDenysPetrov wrote: > Don't you think this is too complicated for such a simple getter? > Maybe we can just construct the range using smth about > `RangeSet(RangeFactory, ++Zero, --Zero);` ? It is more complex than a false range but there is a reason for it. First of all, `RangeSet` can't have ranges where the end is greater than its start. Only `Intersect` can handle such ranges correctly. Another thing is that ranges like that mean `[MIN, --Zero], [++Zero, MAX]` and without a type we can't really say what `MIN` and `MAX` are, so such constructor for `RangeSet` simply cannot exist. Another point is that we do need to have `[MIN, -1], [+1, MAX]` as opposed to `[-1, -1], [+1, +1]` because of C language (it doesn't have boolean type), and because of the cases like `a - b` where we know that `a != b`. I hope that answers the question. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82381/new/ https://reviews.llvm.org/D82381 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits