[PATCH] D149259: [analyzer][NFC] Use std::optional instead of custom "empty" state

DonĂ¡t Nagy via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 28 01:22:50 PDT 2023


donat.nagy updated this revision to Diff 517831.
donat.nagy edited the summary of this revision.
donat.nagy added a comment.

As I was finalizing this commit, I noticed that the logic of `RegionRawOffsetV2::computeOffset()` is presented in a ~~crazy~~ unconventional way; so I rewrote it (while preserving the original behavior).

The most convoluted part was that the old code initialized the `offset` variable to `UnknownVal()`, then compensated for this choice by introducing a function `getValue` that always substituted zero when it encountered //this// `UnknownVal()` (no other effect placed `UnknownVal()` into that variable without immediately returning afterwards). I suspect that this initial value was introduced to avoid the analysis of load expressions that do not involve any array indexing (i.e. don't have `ElementRegion` layers), but that logic was broken by a commit in 2011.

@steakhal Can you provide another review for this extended version of the patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149259

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149259.517831.patch
Type: text/x-patch
Size: 7920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230428/3e2b26e0/attachment.bin>


More information about the cfe-commits mailing list