clang 22.0.0git
NullabilityChecker.cpp File Reference

Go to the source code of this file.

Macros

#define REGISTER_CHECKER(NAME, TRACKING_REQUIRED)

Enumerations

enum class  NullConstraint { IsNull , IsNotNull , Unknown }

Functions

 REGISTER_MAP_WITH_PROGRAMSTATE (NullabilityMap, const MemRegion *, NullabilityState) REGISTER_MAP_WITH_PROGRAMSTATE(PropertyAccessesMap
static NullConstraint getNullConstraint (DefinedOrUnknownSVal Val, ProgramStateRef State)
static bool isValidPointerType (QualType T)
static bool checkValueAtLValForInvariantViolation (ProgramStateRef State, SVal LV, QualType T)
 Returns true when the value stored at the given location has been constrained to null after being passed through an object of nonnnull type.
static bool checkParamsForPreconditionViolation (ArrayRef< ParmVarDecl * > Params, ProgramStateRef State, const LocationContext *LocCtxt)
static bool checkSelfIvarsForInvariantViolation (ProgramStateRef State, const LocationContext *LocCtxt)
static bool checkInvariantViolation (ProgramStateRef State, ExplodedNode *N, CheckerContext &C)
static const ExprlookThroughImplicitCasts (const Expr *E)
 Find the outermost subexpression of E that is not an implicit cast.
static Nullability getReceiverNullability (const ObjCMethodCall &M, ProgramStateRef State)
static const ExprmatchValueExprForBind (const Stmt *S)
 For a given statement performing a bind, attempt to syntactically match the expression resulting in the bound value.
static bool isARCNilInitializedLocal (CheckerContext &C, const Stmt *S)
 Returns true if.

Variables

 ObjectPropPair
constexpr llvm::StringLiteral GroupName = "nullability"
constexpr llvm::StringLiteral GroupOptName = "NoDiagnoseCallsToSystemHeaders"

Macro Definition Documentation

◆ REGISTER_CHECKER

#define REGISTER_CHECKER ( NAME,
TRACKING_REQUIRED )
Value:
void ento::register##NAME##Checker(CheckerManager &Mgr) { \
NullabilityChecker *Chk = Mgr.getChecker<NullabilityChecker>(); \
Chk->NAME.enable(Mgr); \
Chk->NeedTracking = Chk->NeedTracking || TRACKING_REQUIRED; \
Chk->NoDiagnoseCallsToSystemHeaders = \
Mgr.getAnalyzerOptions().getCheckerBooleanOption(GroupName, \
GroupOptName, true); \
} \
\
bool ento::shouldRegister##NAME##Checker(const CheckerManager &) { \
return true; \
}
constexpr llvm::StringLiteral GroupOptName
constexpr llvm::StringLiteral GroupName
const AnalyzerOptions & getAnalyzerOptions() const
CHECKER * getChecker(AT &&...Args)
If the the singleton instance of a checker class is not yet constructed, then construct it (with the ...
Simple checker classes that implement one frontend (i.e.
Definition Checker.h:553

Definition at line 1397 of file NullabilityChecker.cpp.

Enumeration Type Documentation

◆ NullConstraint

enum class NullConstraint
strong
Enumerator
IsNull 
IsNotNull 
Unknown 

Definition at line 299 of file NullabilityChecker.cpp.

Function Documentation

◆ checkInvariantViolation()

◆ checkParamsForPreconditionViolation()

bool checkParamsForPreconditionViolation ( ArrayRef< ParmVarDecl * > Params,
ProgramStateRef State,
const LocationContext * LocCtxt )
static

◆ checkSelfIvarsForInvariantViolation()

◆ checkValueAtLValForInvariantViolation()

bool checkValueAtLValForInvariantViolation ( ProgramStateRef State,
SVal LV,
QualType T )
static

Returns true when the value stored at the given location has been constrained to null after being passed through an object of nonnnull type.

Definition at line 377 of file NullabilityChecker.cpp.

References clang::ento::SVal::getAs(), clang::ento::getNullabilityAnnotation(), getNullConstraint(), clang::isa(), IsNull, and clang::T.

Referenced by checkParamsForPreconditionViolation(), and checkSelfIvarsForInvariantViolation().

◆ getNullConstraint()

◆ getReceiverNullability()

◆ isARCNilInitializedLocal()

bool isARCNilInitializedLocal ( CheckerContext & C,
const Stmt * S )
static

Returns true if.

Parameters
Sis a DeclStmt for a local variable that ObjC automated reference counting initialized with zero.

Definition at line 1211 of file NullabilityChecker.cpp.

References clang::C, clang::Init, and clang::isa().

◆ isValidPointerType()

bool isValidPointerType ( QualType T)
static

Definition at line 311 of file NullabilityChecker.cpp.

References clang::T.

◆ lookThroughImplicitCasts()

const Expr * lookThroughImplicitCasts ( const Expr * E)
static

Find the outermost subexpression of E that is not an implicit cast.

This looks through the implicit casts to _Nonnull that ARC adds to return expressions of ObjC types when the return type of the function or method is non-null but the express is not.

Definition at line 645 of file NullabilityChecker.cpp.

References clang::Expr::IgnoreImpCasts().

◆ matchValueExprForBind()

const Expr * matchValueExprForBind ( const Stmt * S)
static

For a given statement performing a bind, attempt to syntactically match the expression resulting in the bound value.

Definition at line 1187 of file NullabilityChecker.cpp.

References clang::Init.

◆ REGISTER_MAP_WITH_PROGRAMSTATE()

REGISTER_MAP_WITH_PROGRAMSTATE ( NullabilityMap ,
const MemRegion * ,
NullabilityState  )

Variable Documentation

◆ GroupName

llvm::StringLiteral GroupName = "nullability"
constexpr

Definition at line 1394 of file NullabilityChecker.cpp.

◆ GroupOptName

llvm::StringLiteral GroupOptName = "NoDiagnoseCallsToSystemHeaders"
constexpr

Definition at line 1395 of file NullabilityChecker.cpp.

◆ ObjectPropPair

ObjectPropPair

Definition at line 270 of file NullabilityChecker.cpp.