[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
Wed Apr 15 04:20:34 PDT 2020


Szelethus added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:229-234
     BufferSizeConstraint(ArgNo BufArgN, ArgNo SizeArgN)
         : ValueConstraint(BufArgN), SizeArgN(SizeArgN) {}
 
+    BufferSizeConstraint(ArgNo BufArgN, ArgNo SizeArgN, ArgNo SizeMulArgN)
+        : ValueConstraint(BufArgN), SizeArgN(SizeArgN),
+          SizeMultiplierArgN(SizeMulArgN) {}
----------------
I don't know, these constructors don't look overly talkative.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1041
+                           EvalCallAsPure)
+                       .ArgConstraint(BufferSize(0, 1, 2))}},
     };
----------------
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?


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