vsavchenko added inline comments.

================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2506-2520
+  for (auto It = NTL.findByWidth(C.getIntWidth(T)) - 1; It >= NTL.begin();
+       --It) {
+    SymbolRef S = State->getSymbolManager().getCastSymbol(
+        RootSym, RootSym->getType(), *It);
+    if (const RangeSet *RS = getConstraint(State, S)) {
+      RangeSet TruncR = F.castTo(R, *It);
+      TruncR = F.intersect(*RS, TruncR);
----------------
What's the point of this when you do reverse operation in `Inferrer`?

As far as I understood, in `VisitSymbolCast`, you iterate over larger types and 
see if the same symbol was casted to any of those, and if yes you truncate the 
result and use that range.
Here, when we are about to set the constraint for a casted symbol, you iterate 
over smaller types, truncate this range for a smaller type, construct a cast to 
that smaller type, and add constraint for that symbol as well.

So, if this is correct, these two pieces of code DO THE SAME WORK and ONLY ONE 
should remain.


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

https://reviews.llvm.org/D103096

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to