clang 22.0.0git
clang::ento::APSIntType Class Reference

A record of the "type" of an APSInt, used for conversions. More...

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

Public Types

enum  RangeTestResultKind { RTR_Below = -1 , RTR_Within = 0 , RTR_Above = 1 }
 Used to classify whether a value is representable using this type. More...

Public Member Functions

constexpr APSIntType (uint32_t Width, bool Unsigned)
 APSIntType (const llvm::APSInt &Value)
uint32_t getBitWidth () const
bool isUnsigned () const
void apply (llvm::APSInt &Value) const
 Convert a given APSInt, in place, to match this type.
llvm::APSInt convert (const llvm::APSInt &Value) const LLVM_READONLY
 Convert and return a new APSInt with the given value, but this type's bit width and signedness.
llvm::APSInt getZeroValue () const LLVM_READONLY
 Returns an all-zero value for this type.
llvm::APSInt getMinValue () const LLVM_READONLY
 Returns the minimum value for this type.
llvm::APSInt getMaxValue () const LLVM_READONLY
 Returns the maximum value for this type.
llvm::APSInt getValue (uint64_t RawValue) const LLVM_READONLY
RangeTestResultKind testInRange (const llvm::APSInt &Val, bool AllowMixedSign) const LLVM_READONLY
 Tests whether a given value is losslessly representable using this type.
bool operator== (const APSIntType &Other) const
bool operator< (const APSIntType &Other) const
 Provide an ordering for finding a common conversion type.

Detailed Description

A record of the "type" of an APSInt, used for conversions.

Definition at line 19 of file APSIntType.h.

Member Enumeration Documentation

◆ RangeTestResultKind

Used to classify whether a value is representable using this type.

See also
testInRange
Enumerator
RTR_Below 

Value is less than the minimum representable value.

RTR_Within 

Value is representable using this type.

RTR_Above 

Value is greater than the maximum representable value.

Definition at line 76 of file APSIntType.h.

Constructor & Destructor Documentation

◆ APSIntType() [1/2]

clang::ento::APSIntType::APSIntType ( uint32_t Width,
bool Unsigned )
inlineconstexpr

Definition at line 24 of file APSIntType.h.

References clang::Unsigned.

Referenced by operator<(), and operator==().

◆ APSIntType() [2/2]

clang::ento::APSIntType::APSIntType ( const llvm::APSInt & Value)
inline

Definition at line 27 of file APSIntType.h.

References getBitWidth(), and isUnsigned().

Member Function Documentation

◆ apply()

void clang::ento::APSIntType::apply ( llvm::APSInt & Value) const
inline

Convert a given APSInt, in place, to match this type.

This behaves like a C cast: converting 255u8 (0xFF) to s16 gives 255 (0x00FF), and converting -1s8 (0xFF) to u16 gives 65535 (0xFFFF).

Definition at line 37 of file APSIntType.h.

Referenced by convert().

◆ convert()

llvm::APSInt clang::ento::APSIntType::convert ( const llvm::APSInt & Value) const
inline

◆ getBitWidth()

◆ getMaxValue()

llvm::APSInt clang::ento::APSIntType::getMaxValue ( ) const
inline

◆ getMinValue()

llvm::APSInt clang::ento::APSIntType::getMinValue ( ) const
inline

Returns the minimum value for this type.

Definition at line 60 of file APSIntType.h.

◆ getValue()

llvm::APSInt clang::ento::APSIntType::getValue ( uint64_t RawValue) const
inline

◆ getZeroValue()

llvm::APSInt clang::ento::APSIntType::getZeroValue ( ) const
inline

Returns an all-zero value for this type.

Definition at line 55 of file APSIntType.h.

Referenced by clang::ento::RangedConstraintManager::assumeSymInclusiveRange(), and clang::ento::RangedConstraintManager::assumeSymRel().

◆ isUnsigned()

◆ operator<()

bool clang::ento::APSIntType::operator< ( const APSIntType & Other) const
inline

Provide an ordering for finding a common conversion type.

Unsigned integers are considered to be better conversion types than signed integers of the same width.

Definition at line 99 of file APSIntType.h.

References APSIntType(), and clang::Other.

◆ operator==()

bool clang::ento::APSIntType::operator== ( const APSIntType & Other) const
inline

Definition at line 91 of file APSIntType.h.

References APSIntType(), and clang::Other.

◆ testInRange()

APSIntType::RangeTestResultKind APSIntType::testInRange ( const llvm::APSInt & Val,
bool AllowMixedSign ) const

Tests whether a given value is losslessly representable using this type.

Parameters
ValThe value to test.
AllowMixedSignWhether or not to allow signedness conversions. This determines whether -1s8 is considered in range for 'unsigned char' (u8).

Definition at line 15 of file APSIntType.cpp.

References RTR_Above, RTR_Below, and RTR_Within.


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