[PATCH] D86873: [analyzer][NFC] Refactor ArrayBoundCheckerV2

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 04:53:28 PDT 2020


steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, xazax.hun, martong, Szelethus.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

This patch refactors the ArrayBoundCheckerV2 to use more SValVisitor machinery.
IMO this pattern leads to a more functional style, thus more readable - compared to an ad-hoc recursion what `getSimplifiedOffsets` did.
I also drastically reduce the scope of the mutated local variables for readability.
This resulted in a fairly large change:

- Use `MemRegionVisitor` to compute `RegionRawOffsetV2` of a memory region.
- Use `SymExprVisitor` to //simplify// subscript expression.
- Remove `getSimplifiedOffsets` function.
- Split up `ArrayBoundCheckerV2::checkLocation` into `checkLowerBound` and `checkUpperBound`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86873

Files:
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86873.288923.patch
Type: text/x-patch
Size: 23145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200831/36401e46/attachment-0001.bin>


More information about the cfe-commits mailing list