[PATCH] D77148: [analyzer] ApiModeling: Add buffer size arg constraint with multiplier involved

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 5 09:41:47 PDT 2020


Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1041
+                           EvalCallAsPure)
+                       .ArgConstraint(BufferSize(0, 1, 2))}},
     };
----------------
martong wrote:
> Szelethus wrote:
> > So this is supposed to mean that the 1st argument has the size of the argument of 2nd argument times the 3rd argument? Unlike the other summaries, this feels a bit cryptic. Something like this might look better:
> > ```lang=c++
> > .ArgConstraint(0, BufferSize(/*BufSize*/1, /*BufSizeMultiplier*/))
> > .ArgConstraint(BufferSize(/*Buffer*/0, /*BufSize*/1, /*BufSizeMultiplier*/2))
> > .ArgConstraint(0, BufferSizeMul(1, 2))
> > ```
> > WDYT?
> Ok, I updated with the 2nd option. :)
Very well!


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:225
+    // The argument which is a multiplier to size. This is set in case of
+    // `fread` like functions where the size is computed as a multiplication of
+    // two arguments.
----------------
fread-like


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77148





More information about the cfe-commits mailing list