clang  10.0.0svn
Namespaces | Functions
RetainCountChecker.cpp File Reference
#include "RetainCountChecker.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
Include dependency graph for RetainCountChecker.cpp:

Go to the source code of this file.


 Dataflow Directional Tag Classes.


const RefVal * clang::ento::retaincountchecker::getRefBinding (ProgramStateRef State, SymbolRef Sym)
static ProgramStateRef setRefBinding (ProgramStateRef State, SymbolRef Sym, RefVal Val)
static ProgramStateRef removeRefBinding (ProgramStateRef State, SymbolRef Sym)
static bool isReceiverUnconsumedSelf (const CallEvent &Call)
static const RetainSummary * getSummary (RetainSummaryManager &Summaries, const CallEvent &Call, QualType ReceiverType)
static QualType GetReturnType (const Expr *RetE, ASTContext &Ctx)
 GetReturnType - Used to get the return type of a message expression or function call with the intention of affixing that type to a tracked symbol. More...
static Optional< RefVal > refValFromRetEffect (RetEffect RE, QualType ResultTy)
static bool isPointerToObject (QualType QT)
static bool shouldEscapeOSArgumentOnCall (const CallEvent &CE, unsigned ArgIdx, const RefVal *TrackedValue)
 Whether the tracked value should be escaped on a given call. More...
static bool isSmartPtrField (const MemRegion *MR)
static bool shouldEscapeRegion (const MemRegion *R)
 A value escapes in these possible cases: More...
static SmallVector< ProgramStateRef, 2 > updateOutParameters (ProgramStateRef State, const RetainSummary &Summ, const CallEvent &CE)
static bool getOption (AnalyzerOptions &Options, StringRef Postfix, StringRef Value)

Function Documentation

◆ getOption()

static bool getOption ( AnalyzerOptions Options,
StringRef  Postfix,
StringRef  Value 

Definition at line 1488 of file RetainCountChecker.cpp.

◆ GetReturnType()

static QualType GetReturnType ( const Expr RetE,
ASTContext Ctx 

GetReturnType - Used to get the return type of a message expression or function call with the intention of affixing that type to a tracked symbol.

While the return type can be queried directly from RetEx, when invoking class methods we augment to the return type to be that of a pointer to the class (as opposed it just being id).

more specific than id.

Definition at line 394 of file RetainCountChecker.cpp.

References clang::Type::getAs(), clang::ASTContext::getObjCInterfaceType(), clang::ASTContext::getObjCObjectPointerType(), and clang::Expr::getType().

Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkSummary().

◆ getSummary()

static const RetainSummary* getSummary ( RetainSummaryManager &  Summaries,
const CallEvent Call,
QualType  ReceiverType 

◆ isPointerToObject()

static bool isPointerToObject ( QualType  QT)

◆ isReceiverUnconsumedSelf()

static bool isReceiverUnconsumedSelf ( const CallEvent Call)

◆ isSmartPtrField()

static bool isSmartPtrField ( const MemRegion MR)

Definition at line 488 of file RetainCountChecker.cpp.

Referenced by shouldEscapeRegion().

◆ refValFromRetEffect()

static Optional<RefVal> refValFromRetEffect ( RetEffect  RE,
QualType  ResultTy 

◆ removeRefBinding()

static ProgramStateRef removeRefBinding ( ProgramStateRef  State,
SymbolRef  Sym 

◆ setRefBinding()

static ProgramStateRef setRefBinding ( ProgramStateRef  State,
SymbolRef  Sym,
RefVal  Val 

◆ shouldEscapeOSArgumentOnCall()

static bool shouldEscapeOSArgumentOnCall ( const CallEvent CE,
unsigned  ArgIdx,
const RefVal *  TrackedValue 

Whether the tracked value should be escaped on a given call.

OSObjects are escaped when passed to void * / etc.

Definition at line 436 of file RetainCountChecker.cpp.

References isPointerToObject(), clang::ento::OS, and clang::ento::CallEvent::parameters().

Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkSummary(), and clang::ento::retaincountchecker::RetainCountChecker::processSummaryOfInlined().

◆ shouldEscapeRegion()

static bool shouldEscapeRegion ( const MemRegion R)

A value escapes in these possible cases:

  • binding to something that is not a memory region.
  • binding to a memregion that does not have stack storage
  • binding to a variable that has a destructor attached using CleanupAttr

We do not currently model what happens when a symbol is assigned to a struct field, unless it is a known smart pointer implementation, about which we know that it is inlined. FIXME: This could definitely be improved upon.

Definition at line 505 of file RetainCountChecker.cpp.

References clang::Decl::hasAttr(), clang::ento::MemRegion::hasStackStorage(), and isSmartPtrField().

Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkBind(), and updateOutParameters().

◆ updateOutParameters()

static SmallVector<ProgramStateRef, 2> updateOutParameters ( ProgramStateRef  State,
const RetainSummary &  Summ,
const CallEvent CE