22#ifndef LLVM_CLANG_STATICANALYZER_CHECKERS_BOUNDSCHECKING_H
23#define LLVM_CLANG_STATICANALYZER_CHECKERS_BOUNDSCHECKING_H
42 std::optional<NonLoc> Extent,
CheckFlags Flags);
64 bool mayOverflow()
const {
return ExtentIfMayOverflow.has_value(); }
66 bool mayBeInvalid()
const {
return MayUnderflow || ExtentIfMayOverflow; }
75 return ExtentIfMayOverflow;
86 NonLoc Offset, std::optional<NonLoc> Extent,
95 explicit CheckResult(
NonLoc Offs) : Offset(Offs) {}
97 bool IsCorruptedState =
false;
98 bool MayUnderflow =
false;
99 std::optional<NonLoc> ExtentIfMayOverflow = std::nullopt;
bool mayBeInBounds() const
When true, the checked offset may be in bounds.
bool mayBeInvalid() const
When true, the checked offset may be out of bounds.
bool mayUnderflow() const
When true, the checked offset may be negative.
NonLoc getOffset() const
Returns the offset of the accessed location from the beginning of the accessd region.
friend CheckResult checkBounds(ProgramStateRef State, SValBuilder &SVB, NonLoc Offset, std::optional< NonLoc > Extent, CheckFlags Flags)
Checks the validity of accessing a memory region with extent Extent at offset Offset.
ProgramStateRef getInBoundsState() const
Returns the program state that should be used for continuing the analysis after this bounds check.
bool mayOverflow() const
When true, the checked offset may be >= the extent of the region.
bool isCorruptedState() const
When true, the bounds check noticed that the value of an unsigned expression is constrained to negati...
std::optional< NonLoc > getExtentIfMayOverflow() const
Returns the extent of the accessed region if it is relevant (because the offset may overflow it),...
CheckResult checkBounds(ProgramStateRef State, SValBuilder &SVB, NonLoc Offset, std::optional< NonLoc > Extent, CheckFlags Flags)
Checks the validity of accessing a memory region with extent Extent at offset Offset.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
unsigned AcceptPastTheEnd
unsigned OffsetObviouslyNonnegative