[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.
Denys Petrov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 27 10:16:28 PDT 2021
ASDenysPetrov added a comment.
I'll do an update soon taking into account all the suggestions.
> Please, try to focus on marking inline comments done if you accomplished them.
In the next update.
================
Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1706-1743
+ // Check offsets for being out of bounds.
// C++20 [expr.add] 7.6.6.4 (excerpt):
// If P points to an array element i of an array object x with n
// elements, where i < 0 or i > n, the behavior is undefined.
// Dereferencing is not allowed on the "one past the last
// element", when i == n.
// Example:
----------------
martong wrote:
> ASDenysPetrov wrote:
> > martong wrote:
> > > Perhaps this hunk could be in an individual implementation function?
> > There are two //returns// inside the loop. That would not such easy to do a separate function for this.
> > There are two //returns// inside the loop. That would not such easy to do a separate function for this.
>
> I think you could return with an `Optional<SVal>` and then in the call site you could check if the optional is set.
> `Optional<SVal> areOffsetsOutOfBounds(...)` ?
>
> Then in the caller:
> ```
> if (Optional<SVal> CheckResult = areOffsetsOutOfBounds(...))
> return *CheckResult;
> ```
Great idea.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111654/new/
https://reviews.llvm.org/D111654
More information about the cfe-commits
mailing list