clang 18.0.0git
Functions
ArrayBoundCheckerV2.cpp File Reference
#include "clang/AST/CharUnits.h"
#include "clang/AST/ParentMapContext.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Checkers/Taint.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

Go to the source code of this file.

Functions

static std::optional< std::pair< const SubRegion *, NonLoc > > computeOffset (ProgramStateRef State, SValBuilder &SVB, SVal Location)
 For a given Location that can be represented as a symbolic expression Arr[Idx] (or perhaps Arr[Idx1][Idx2] etc.), return the parent memory block Arr and the distance of Location from the beginning of Arr (expressed in a NonLoc that specifies the number of CharUnits).
 
static std::pair< NonLoc, nonloc::ConcreteIntgetSimplifiedOffsets (NonLoc offset, nonloc::ConcreteInt extent, SValBuilder &svalBuilder)
 
static std::pair< ProgramStateRef, ProgramStateRefcompareValueToThreshold (ProgramStateRef State, NonLoc Value, NonLoc Threshold, SValBuilder &SVB, bool CheckEquality=false)
 
static std::string getRegionName (const SubRegion *Region)
 
static std::optional< int64_t > getConcreteValue (NonLoc SV)
 
static std::string getShortMsg (OOB_Kind Kind, std::string RegName)
 
static Messages getPrecedesMsgs (const SubRegion *Region, NonLoc Offset)
 
static Messages getExceedsMsgs (ASTContext &ACtx, const SubRegion *Region, NonLoc Offset, NonLoc Extent, SVal Location)
 
static Messages getTaintMsgs (const SubRegion *Region, const char *OffsetName)
 

Function Documentation

◆ compareValueToThreshold()

static std::pair< ProgramStateRef, ProgramStateRef > compareValueToThreshold ( ProgramStateRef  State,
NonLoc  Value,
NonLoc  Threshold,
SValBuilder SVB,
bool  CheckEquality = false 
)
static

◆ computeOffset()

static std::optional< std::pair< const SubRegion *, NonLoc > > computeOffset ( ProgramStateRef  State,
SValBuilder SVB,
SVal  Location 
)
static

For a given Location that can be represented as a symbolic expression Arr[Idx] (or perhaps Arr[Idx1][Idx2] etc.), return the parent memory block Arr and the distance of Location from the beginning of Arr (expressed in a NonLoc that specifies the number of CharUnits).

Returns nullopt when these cannot be determined.

Definition at line 86 of file ArrayBoundCheckerV2.cpp.

References clang::ento::SValBuilder::evalBinOpNN(), clang::ento::SValBuilder::getArrayIndexType(), clang::ento::MemRegion::getAs(), clang::ento::SVal::getAs(), clang::ento::SVal::getAsRegion(), clang::ento::SValBuilder::getContext(), clang::ento::ElementRegion::getElementType(), clang::ento::ElementRegion::getIndex(), clang::CharUnits::getQuantity(), clang::ento::SubRegion::getSuperRegion(), clang::ASTContext::getTypeSizeInChars(), clang::Type::isIncompleteType(), clang::ento::SValBuilder::makeArrayIndex(), and clang::ento::SValBuilder::makeZeroArrayIndex().

◆ getConcreteValue()

static std::optional< int64_t > getConcreteValue ( NonLoc  SV)
static

Definition at line 235 of file ArrayBoundCheckerV2.cpp.

References clang::ento::SVal::getAs().

Referenced by getExceedsMsgs().

◆ getExceedsMsgs()

static Messages getExceedsMsgs ( ASTContext ACtx,
const SubRegion Region,
NonLoc  Offset,
NonLoc  Extent,
SVal  Location 
)
static

◆ getPrecedesMsgs()

static Messages getPrecedesMsgs ( const SubRegion Region,
NonLoc  Offset 
)
static

Definition at line 251 of file ArrayBoundCheckerV2.cpp.

References getRegionName(), and getShortMsg().

◆ getRegionName()

static std::string getRegionName ( const SubRegion Region)
static

◆ getShortMsg()

static std::string getShortMsg ( OOB_Kind  Kind,
std::string  RegName 
)
static

Definition at line 242 of file ArrayBoundCheckerV2.cpp.

Referenced by getExceedsMsgs(), and getPrecedesMsgs().

◆ getSimplifiedOffsets()

static std::pair< NonLoc, nonloc::ConcreteInt > getSimplifiedOffsets ( NonLoc  offset,
nonloc::ConcreteInt  extent,
SValBuilder svalBuilder 
)
static

◆ getTaintMsgs()

static Messages getTaintMsgs ( const SubRegion Region,
const char *  OffsetName 
)
static

Definition at line 313 of file ArrayBoundCheckerV2.cpp.

References getRegionName().