clang  14.0.0git
Public Member Functions | List of all members
clang::ento::RangeSet::Factory Class Reference

#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"

Public Member Functions

 Factory (BasicValueFactory &BV)
 
RangeSet add (RangeSet LHS, RangeSet RHS)
 Create a new set with all ranges from both LHS and RHS. More...
 
RangeSet add (RangeSet Original, Range Element)
 Create a new set with all ranges from the original set plus the new one. More...
 
RangeSet add (RangeSet Original, const llvm::APSInt &Point)
 Create a new set with all ranges from the original set plus the point. More...
 
RangeSet getEmptySet ()
 
RangeSet intersect (RangeSet LHS, RangeSet RHS)
 Intersect the given range sets. More...
 
RangeSet intersect (RangeSet What, llvm::APSInt Lower, llvm::APSInt Upper)
 Intersect the given set with the closed range [Lower, Upper]. More...
 
RangeSet intersect (RangeSet What, llvm::APSInt Point)
 Intersect the given range with the given point. More...
 
RangeSet deletePoint (RangeSet From, const llvm::APSInt &Point)
 Delete the given point from the range set. More...
 
RangeSet negate (RangeSet What)
 Negate the given range set. More...
 
BasicValueFactorygetValueFactory () const
 Return associated value factory. More...
 
RangeSet getRangeSet (Range Origin)
 Create a new set with just one range. More...
 
RangeSet getRangeSet (const llvm::APSInt &From, const llvm::APSInt &To)
 
RangeSet getRangeSet (const llvm::APSInt &Origin)
 

Detailed Description

Definition at line 121 of file RangedConstraintManager.h.

Constructor & Destructor Documentation

◆ Factory()

clang::ento::RangeSet::Factory::Factory ( BasicValueFactory BV)
inline

Definition at line 123 of file RangedConstraintManager.h.

Member Function Documentation

◆ add() [1/3]

RangeSet RangeSet::Factory::add ( RangeSet  LHS,
RangeSet  RHS 
)

Create a new set with all ranges from both LHS and RHS.

Possible intersections are not checked here.

Complexity: O(N + M) where N = size(LHS), M = size(RHS)

Definition at line 158 of file RangeConstraintManager.cpp.

References clang::ento::RangeSet::begin(), and clang::ento::RangeSet::end().

◆ add() [2/3]

RangeSet RangeSet::Factory::add ( RangeSet  Original,
const llvm::APSInt Point 
)

Create a new set with all ranges from the original set plus the point.

Possible intersections are not checked here.

Complexity: O(N) where N = size(Original)

Definition at line 125 of file RangeConstraintManager.cpp.

◆ add() [3/3]

RangeSet RangeSet::Factory::add ( RangeSet  Original,
Range  Element 
)

Create a new set with all ranges from the original set plus the new one.

Possible intersections are not checked here.

Complexity: O(N) where N = size(Original)

Definition at line 113 of file RangeConstraintManager.cpp.

References clang::ento::RangeSet::begin(), clang::ento::RangeSet::end(), and clang::ento::RangeSet::size().

◆ deletePoint()

RangeSet RangeSet::Factory::deletePoint ( RangeSet  From,
const llvm::APSInt Point 
)

Delete the given point from the range set.

Complexity: O(N) where N = size(From)

Definition at line 482 of file RangeConstraintManager.cpp.

◆ getEmptySet()

RangeSet clang::ento::RangeSet::Factory::getEmptySet ( )
inline

Definition at line 144 of file RangedConstraintManager.h.

◆ getRangeSet() [1/3]

RangeSet clang::ento::RangeSet::Factory::getRangeSet ( const llvm::APSInt From,
const llvm::APSInt To 
)
inline

Definition at line 149 of file RangedConstraintManager.h.

References getRangeSet().

◆ getRangeSet() [2/3]

RangeSet clang::ento::RangeSet::Factory::getRangeSet ( const llvm::APSInt Origin)
inline

Definition at line 152 of file RangedConstraintManager.h.

References getRangeSet().

◆ getRangeSet() [3/3]

RangeSet clang::ento::RangeSet::Factory::getRangeSet ( Range  Origin)

Create a new set with just one range.

Referenced by getRangeSet().

◆ getValueFactory()

BasicValueFactory& clang::ento::RangeSet::Factory::getValueFactory ( ) const
inline

Return associated value factory.

Definition at line 218 of file RangedConstraintManager.h.

◆ intersect() [1/3]

RangeSet RangeSet::Factory::intersect ( RangeSet  LHS,
RangeSet  RHS 
)

Intersect the given range sets.

Complexity: O(N + M) where N = size(LHS), M = size(RHS)

Definition at line 403 of file RangeConstraintManager.cpp.

References clang::ento::RangeSet::getMaxValue(), clang::ento::RangeSet::getMinValue(), and clang::ento::RangeSet::isEmpty().

◆ intersect() [2/3]

RangeSet RangeSet::Factory::intersect ( RangeSet  What,
llvm::APSInt  Lower,
llvm::APSInt  Upper 
)

Intersect the given set with the closed range [Lower, Upper].

Unlike the Range type, this range uses modular arithmetic, corresponding to the common treatment of C integer overflow. Thus, if the Lower bound is greater than the Upper bound, the range is taken to wrap around. This is equivalent to taking the intersection with the two ranges [Min, Upper] and [Lower, Max], or, alternatively, /removing/ all integers between Upper and Lower.

Complexity: O(N) where N = size(What)

Definition at line 277 of file RangeConstraintManager.cpp.

References clang::ento::RangeSet::getMaxValue(), clang::ento::RangeSet::getMinValue(), and clang::ento::RangeSet::isEmpty().

◆ intersect() [3/3]

RangeSet clang::ento::RangeSet::Factory::intersect ( RangeSet  What,
llvm::APSInt  Point 
)

Intersect the given range with the given point.

The result can be either an empty set or a set containing the given point depending on whether the point is in the range set.

Complexity: O(logN) where N = size(What)

◆ negate()

RangeSet RangeSet::Factory::negate ( RangeSet  What)

Negate the given range set.

Turn all [A, B] ranges to [-B, -A], when "-" is a C-like unary minus operation under the values of the type.

We also handle MIN because applying unary minus to MIN does not change it. Example 1: char x = -128; // -128 is a MIN value in a range of 'char' char y = -x; // y: -128

Example 2: unsigned char x = 0; // 0 is a MIN value in a range of 'unsigned char' unsigned char y = -x; // y: 0

And it makes us to separate the range like [MIN, N] to [MIN, MIN] U [-N, MAX]. For instance, whole range is {-128..127} and subrange is [-128,-126], thus [-128,-127,-126,...] negates to [-128,...,126,127].

Negate restores disrupted ranges on bounds, e.g. [MIN, B] => [MIN, MIN] U [-B, MAX] => [MIN, B].

Negate is a self-inverse function, i.e. negate(negate(R)) == R.

Complexity: O(N) where N = size(What)

Definition at line 419 of file RangeConstraintManager.cpp.

References clang::ento::RangeSet::begin(), clang::ento::RangeSet::end(), End, clang::ento::Range::From(), clang::ento::RangeSet::getMinValue(), clang::ento::RangeSet::isEmpty(), clang::Last, and clang::ento::RangeSet::size().


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