[PATCH] D105436: [analyzer][solver] Use all sources of constraints

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 6 03:03:23 PDT 2021


martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:908
+        // into subexpressions of Sym.
+        Visit(Sym));
   }
----------------
vsavchenko wrote:
> martong wrote:
> > Alright. So, this is correct because `Visit` boils down finally to either `infer(Sym->getType)` or to `VisitBinaryOperator`. And both of them do a correct over-approximation of the ranges. Please confirm. 
> > 
> > First, I was a bit concerned b/c it is not immediate and not documented here. And it is easy to think by the first look that this might be faulty if we take the approximation of one operand of a binop that might not be true for the whole binop expression. Again, that is not the case because we approximate only in case of such ops where we can do a correct over-approximation (i.e. `|`, `&` and `%`). 
> > 
> > My point is, I'd like to see more explanatory comments here.
> I'm sorry, but I don't really understand your point here.
> 
> Everything that this solver provides is conservative ranges, from whatever source it comes.  If you intersect two conservative ranges, you get a conservative range.
> It doesn't matter what we do in `Visit` as long as it is correct.  If `Visit` is incorrect then the previous version of this code that gave preference to some sources over the other ones was also incorrect.
Thanks for your reply.  So, with other words, I didn't see why it is immediate that a range for a sub-expression is a good approximation for the whole expression. Maybe it's just me, but that's not obvious until one checks that what exactly happens in `Visit`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105436/new/

https://reviews.llvm.org/D105436



More information about the cfe-commits mailing list