clang 24.0.0git
clang::ento::bounds::CheckResult Class Reference

#include "clang/StaticAnalyzer/Checkers/BoundsChecking.h"

Public Member Functions

bool isCorruptedState () const
 When true, the bounds check noticed that the value of an unsigned expression is constrained to negative values (because the analyzer skipped the modeling of a cast expression).
bool mayBeInBounds () const
 When true, the checked offset may be in bounds.
bool mayUnderflow () const
 When true, the checked offset may be negative.
bool mayOverflow () const
 When true, the checked offset may be >= the extent of the region.
bool mayBeInvalid () const
 When true, the checked offset may be out of bounds.
NonLoc getOffset () const
 Returns the offset of the accessed location from the beginning of the accessd region.
std::optional< NonLocgetExtentIfMayOverflow () const
 Returns the extent of the accessed region if it is relevant (because the offset may overflow it), otherwise returns std::nullopt.
ProgramStateRef getInBoundsState () const
 Returns the program state that should be used for continuing the analysis after this bounds check.

Friends

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.

Detailed Description

Definition at line 41 of file BoundsChecking.h.

Member Function Documentation

◆ getExtentIfMayOverflow()

std::optional< NonLoc > clang::ento::bounds::CheckResult::getExtentIfMayOverflow ( ) const
inline

Returns the extent of the accessed region if it is relevant (because the offset may overflow it), otherwise returns std::nullopt.

Definition at line 67 of file BoundsChecking.h.

Referenced by describeInvalidAccess(), and getAssumptionNote().

◆ getInBoundsState()

ProgramStateRef clang::ento::bounds::CheckResult::getInBoundsState ( ) const
inline

Returns the program state that should be used for continuing the analysis after this bounds check.

This returns null if mayBeInBounds() is false, in that case the state before the check should be used in the error node.

Definition at line 74 of file BoundsChecking.h.

◆ getOffset()

NonLoc clang::ento::bounds::CheckResult::getOffset ( ) const
inline

Returns the offset of the accessed location from the beginning of the accessd region.

Definition at line 63 of file BoundsChecking.h.

Referenced by describeInvalidAccess(), and getAssumptionNote().

◆ isCorruptedState()

bool clang::ento::bounds::CheckResult::isCorruptedState ( ) const
inline

When true, the bounds check noticed that the value of an unsigned expression is constrained to negative values (because the analyzer skipped the modeling of a cast expression).

This execution path must be discarded because it does not represent a real possibility. FIXME: This hack is currently needed to filter out many ugly false positives; but it should be removed when we fix cast modeling.

Definition at line 49 of file BoundsChecking.h.

◆ mayBeInBounds()

bool clang::ento::bounds::CheckResult::mayBeInBounds ( ) const
inline

When true, the checked offset may be in bounds.

Definition at line 52 of file BoundsChecking.h.

◆ mayBeInvalid()

bool clang::ento::bounds::CheckResult::mayBeInvalid ( ) const
inline

When true, the checked offset may be out of bounds.

Definition at line 59 of file BoundsChecking.h.

Referenced by describeInvalidAccess(), and describeTaintBug().

◆ mayOverflow()

bool clang::ento::bounds::CheckResult::mayOverflow ( ) const
inline

When true, the checked offset may be >= the extent of the region.

Definition at line 57 of file BoundsChecking.h.

Referenced by describeInvalidAccess(), describeTaintBug(), and getAssumptionNote().

◆ mayUnderflow()

bool clang::ento::bounds::CheckResult::mayUnderflow ( ) const
inline

When true, the checked offset may be negative.

Definition at line 55 of file BoundsChecking.h.

Referenced by describeInvalidAccess(), describeTaintBug(), and getAssumptionNote().

◆ checkBounds

CheckResult checkBounds ( ProgramStateRef State,
SValBuilder & SVB,
NonLoc Offset,
std::optional< NonLoc > Extent,
CheckFlags Flags )
friend

Checks the validity of accessing a memory region with extent Extent at offset Offset.

The Flags influence the semantics of the check.


The documentation for this class was generated from the following file: