[PATCH] D23112: [analyzer] Correctly add assumptions based on array bounds.

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 03:19:41 PDT 2016


xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, NoQ.
xazax.hun added a subscriber: cfe-commits.

Right now due to a missing brace error the assumptions that an index is inbound in case we are under constrained is not added.

https://reviews.llvm.org/D23112

Files:
  lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp

Index: lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -157,13 +157,13 @@
 
     // If we are under constrained and the index variables are tainted, report.
     if (state_exceedsUpperBound && state_withinUpperBound) {
-      if (state->isTainted(rawOffset.getByteOffset()))
+      if (state->isTainted(rawOffset.getByteOffset())) {
         reportOOB(checkerContext, state_exceedsUpperBound, OOB_Tainted);
         return;
-    }
-
-    // If we are constrained enough to definitely exceed the upper bound, report.
-    if (state_exceedsUpperBound) {
+      }
+    } else if (state_exceedsUpperBound) {
+      // If we are constrained enough to definitely exceed the upper bound,
+      // report.
       assert(!state_withinUpperBound);
       reportOOB(checkerContext, state_exceedsUpperBound, OOB_Excedes);
       return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23112.66635.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160803/d108c744/attachment.bin>


More information about the cfe-commits mailing list