30class ObjCContainersChecker :
public Checker< check::PreStmt<CallExpr>,
31 check::PostStmt<CallExpr>,
32 check::PointerEscape> {
41 void addSizeInfo(
const Expr *Array,
const Expr *Size,
53 const char *NL,
const char *Sep)
const override;
60void ObjCContainersChecker::addSizeInfo(
const Expr *Array,
const Expr *Size,
63 SVal SizeV =
C.getSVal(Size);
78void ObjCContainersChecker::checkPostStmt(
const CallExpr *CE,
80 StringRef Name =
C.getCalleeName(CE);
85 if (Name ==
"CFArrayCreate") {
91 addSizeInfo(CE, CE->
getArg(2),
C);
95 if (Name ==
"CFArrayGetCount") {
96 addSizeInfo(CE->
getArg(0), CE,
C);
101void ObjCContainersChecker::checkPreStmt(
const CallExpr *CE,
103 StringRef Name =
C.getCalleeName(CE);
108 if (Name ==
"CFArrayGetValueAtIndex") {
114 SymbolRef ArraySym = getArraySym(ArrayExpr,
C);
125 SVal IdxVal =
C.getSVal(IdxExpr);
133 std::tie(StInBound, StOutBound) = State->assumeInBoundDual(Idx, *Size,
T);
134 if (StOutBound && !StInBound) {
139 auto R = std::make_unique<PathSensitiveBugReport>(
140 BT,
"Index is out of bounds", N);
143 {bugreporter::TrackingKind::Thorough,
145 C.emitReport(std::move(R));
156 for (
const auto &Sym : Escaped) {
162 State = State->remove<ArraySizeMap>(Sym);
167void ObjCContainersChecker::printState(raw_ostream &OS,
ProgramStateRef State,
168 const char *NL,
const char *Sep)
const {
169 ArraySizeMapTy Map = State->get<ArraySizeMap>();
173 OS << Sep <<
"ObjC container sizes :" << NL;
175 OS << I.first <<
" : " << I.second << NL;
184bool ento::shouldRegisterObjCContainersChecker(
const CheckerManager &mgr) {
#define REGISTER_MAP_WITH_PROGRAMSTATE(Name, Key, Value)
Declares an immutable map of type NameTy, suitable for placement into the ProgramState.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
This represents one expression.
A (possibly-)qualified type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Represents an abstract call to a function or method along a particular path.
virtual void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const
See CheckerManager::runCheckersForPrintState.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
bool isUnknownOrUndef() const
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
bool trackExpressionValue(const ExplodedNode *N, const Expr *E, PathSensitiveBugReport &R, TrackingOptions Opts={})
Attempts to add visitors to track expression value back to its point of origin.
const char *const CoreFoundationObjectiveC
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
llvm::DenseSet< SymbolRef > InvalidatedSymbols
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T