clang 20.0.0git
Macros | Enumerations | Functions | Variables
NullabilityChecker.cpp File Reference
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/Analysis/AnyCall.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/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Path.h"

Go to the source code of this file.

Macros

#define REGISTER_CHECKER(name, trackingRequired)
 

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
 

Macro Definition Documentation

◆ REGISTER_CHECKER

#define REGISTER_CHECKER (   name,
  trackingRequired 
)
Value:
void ento::register##name##Checker(CheckerManager &mgr) { \
NullabilityChecker *checker = mgr.getChecker<NullabilityChecker>(); \
checker->ChecksEnabled[NullabilityChecker::CK_##name] = true; \
checker->CheckNames[NullabilityChecker::CK_##name] = \
checker->NeedTracking = checker->NeedTracking || trackingRequired; \
checker->NoDiagnoseCallsToSystemHeaders = \
checker->NoDiagnoseCallsToSystemHeaders || \
checker, "NoDiagnoseCallsToSystemHeaders", true); \
} \
\
bool ento::shouldRegister##name##Checker(const CheckerManager &mgr) { \
return true; \
}
bool getCheckerBooleanOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
Interprets an option's string value as a boolean.
const AnalyzerOptions & getAnalyzerOptions() const
CheckerNameRef getCurrentCheckerName() const

Definition at line 1397 of file NullabilityChecker.cpp.

Enumeration Type Documentation

◆ NullConstraint

enum class NullConstraint
strong
Enumerator
IsNull 
IsNotNull 
Unknown 

Definition at line 301 of file NullabilityChecker.cpp.

Function Documentation

◆ checkInvariantViolation()

static bool checkInvariantViolation ( ProgramStateRef  State,
ExplodedNode N,
CheckerContext C 
)
static

◆ checkParamsForPreconditionViolation()

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

◆ checkSelfIvarsForInvariantViolation()

static bool checkSelfIvarsForInvariantViolation ( ProgramStateRef  State,
const LocationContext LocCtxt 
)
static

◆ checkValueAtLValForInvariantViolation()

static 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 379 of file NullabilityChecker.cpp.

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

Referenced by checkParamsForPreconditionViolation(), and checkSelfIvarsForInvariantViolation().

◆ getNullConstraint()

static NullConstraint getNullConstraint ( DefinedOrUnknownSVal  Val,
ProgramStateRef  State 
)
static

◆ getReceiverNullability()

static Nullability getReceiverNullability ( const ObjCMethodCall M,
ProgramStateRef  State 
)
static

◆ isARCNilInitializedLocal()

static 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 1210 of file NullabilityChecker.cpp.

References clang::C, and clang::Init.

◆ isValidPointerType()

static bool isValidPointerType ( QualType  T)
static

◆ lookThroughImplicitCasts()

static 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 647 of file NullabilityChecker.cpp.

References E, and clang::Expr::IgnoreImpCasts().

◆ matchValueExprForBind()

static 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 1186 of file NullabilityChecker.cpp.

References clang::Init.

◆ REGISTER_MAP_WITH_PROGRAMSTATE()

REGISTER_MAP_WITH_PROGRAMSTATE ( NullabilityMap  ,
const MemRegion ,
NullabilityState   
)

Variable Documentation

◆ ObjectPropPair

ObjectPropPair

Definition at line 272 of file NullabilityChecker.cpp.