clang 8.0.0

Public Types | Public Member Functions | List of all members
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
| 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. More...
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. More...
llvm::APSInt | getZeroValue () const LLVM_READONLY
| Returns an all-zero value for this type. More...
llvm::APSInt | getMinValue () const LLVM_READONLY
| Returns the minimum value for this type. More...
llvm::APSInt | getMaxValue () const LLVM_READONLY
| Returns the maximum value for this type. More...
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. More...
bool | operator== (const APSIntType &Other) const
bool | operator< (const APSIntType &Other) const
| Provide an ordering for finding a common conversion type. More...

## Detailed Description

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

Definition at line 20 of file APSIntType.h.

## Member Enumeration Documentation

## ◆ RangeTestResultKind

enum clang::ento::APSIntType::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 77 of file APSIntType.h.

## Constructor & Destructor Documentation

## ◆ APSIntType() [1/2]

clang::ento::APSIntType::APSIntType | ( | uint32_t | Width,
|  | bool | Unsigned
| ) |  |
| inline

Definition at line 25 of file APSIntType.h.

## ◆ APSIntType() [2/2]

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

Definition at line 28 of file APSIntType.h.

## 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 38 of file APSIntType.h.

Referenced by convert().

## ◆ convert()

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

Convert and return a new APSInt with the given value, but this type's bit width and signedness.

See also
  apply

Definition at line 49 of file APSIntType.h.

References apply().

Referenced by clang::ento::RangedConstraintManager::assumeSymInclusiveRange(), clang::ento::RangedConstraintManager::assumeSymRel(), clang::ento::SMTConv::castAPSInt(), and clang::ento::BasicValueFactory::Convert().

## ◆ getBitWidth()

uint32_t clang::ento::APSIntType::getBitWidth | ( |  | ) | const
| inline

Definition at line 31 of file APSIntType.h.

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

## ◆ getMaxValue()

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

Returns the maximum value for this type.

Definition at line 66 of file APSIntType.h.

Referenced by clang::ento::SValBuilder::evalIntegralCast().

## ◆ getMinValue()

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

Returns the minimum value for this type.

Definition at line 61 of file APSIntType.h.

## ◆ getValue()

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

Definition at line 70 of file APSIntType.h.

## ◆ getZeroValue()

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

Returns an all-zero value for this type.

Definition at line 56 of file APSIntType.h.

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

## ◆ isUnsigned()

bool clang::ento::APSIntType::isUnsigned | ( |  | ) | const
| inline

Definition at line 32 of file APSIntType.h.

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

## ◆ 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 100 of file APSIntType.h.

## ◆ operator==()

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

Definition at line 92 of file APSIntType.h.

## ◆ testInRange()

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

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

Parameters

  Val | The value to test.
  AllowMixedSign | Whether or not to allow signedness conversions. This determines whether -1s8 is considered in range for 'unsigned char' (u8).

Definition at line 16 of file APSIntType.cpp.

References RTR_Above, RTR_Below, and RTR_Within.

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

- include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h
- lib/StaticAnalyzer/Core/APSIntType.cpp