NoQ added inline comments.

================
Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:130-131
+        // At least check for zero again.
+        // Assume that this is a more exact fact than the previous assumptions
+        // (in checkVLAIndexSize), so report error too.
+        reportBug(VLA_Zero, SizeE, State, C);
----------------
Why not do the same in `checkVLAIndexSize` then?


================
Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:182-183
 
-  SVal LessThanZeroVal = SVB.evalBinOp(State, BO_LT, SizeD, Zero, SizeTy);
-  if (Optional<DefinedSVal> LessThanZeroDVal =
-          LessThanZeroVal.getAs<DefinedSVal>()) {
-    ConstraintManager &CM = C.getConstraintManager();
-    ProgramStateRef StatePos, StateNeg;
+  // Check if the size is zero or negative.
+  SVal PositiveVal = SVB.evalBinOp(State, BO_GT, SizeD, Zero, SizeTy);
+  if (Optional<DefinedSVal> PositiveDVal = PositiveVal.getAs<DefinedSVal>()) {
----------------
The type of binary operator `>=` is `bool`, not `size_t`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81061



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

Reply via email to