clang  6.0.0svn
Macros | Enumerations | Functions
NullabilityChecker.cpp File Reference
#include "ClangSACheckers.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/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Path.h"
Include dependency graph for NullabilityChecker.cpp:

Go to the source code of this file.

Macros

#define REGISTER_CHECKER(name, trackingRequired)
 

Enumerations

enum  Nullability : char
 
enum  ErrorKind : int
 

Functions

 REGISTER_MAP_WITH_PROGRAMSTATE (NullabilityMap, const MemRegion *, NullabilityState) enum class NullConstraint
 
static NullConstraint getNullConstraint (DefinedOrUnknownSVal Val, ProgramStateRef State)
 
static Nullability getNullabilityAnnotation (QualType Type)
 
static bool checkValueAtLValForInvariantViolation (ProgramStateRef State, SVal LV, QualType T)
 Returns true when the value stored at the given location is null and the passed in type is nonnnull. More...
 
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. More...
 
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. More...
 
static bool isARCNilInitializedLocal (CheckerContext &C, const Stmt *S)
 Returns true if. More...
 

Macro Definition Documentation

◆ REGISTER_CHECKER

#define REGISTER_CHECKER (   name,
  trackingRequired 
)
Value:
void ento::register##name##Checker(CheckerManager &mgr) { \
NullabilityChecker *checker = mgr.registerChecker<NullabilityChecker>(); \
checker->Filter.Check##name = true; \
checker->Filter.CheckName##name = mgr.getCurrentCheckName(); \
checker->NeedTracking = checker->NeedTracking || trackingRequired; \
checker->NoDiagnoseCallsToSystemHeaders = \
checker->NoDiagnoseCallsToSystemHeaders || \
mgr.getAnalyzerOptions().getBooleanOption( \
"NoDiagnoseCallsToSystemHeaders", false, checker, true); \
}
CheckName getCurrentCheckName() const
CHECKER * registerChecker()
Used to register checkers.

Definition at line 1217 of file NullabilityChecker.cpp.

Enumeration Type Documentation

◆ ErrorKind

enum ErrorKind : int
strong

Definition at line 85 of file NullabilityChecker.cpp.

◆ Nullability

enum Nullability : char
strong

Definition at line 49 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

Definition at line 382 of file NullabilityChecker.cpp.

References checkValueAtLValForInvariantViolation().

Referenced by checkInvariantViolation().

◆ 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 is null and the passed in type is nonnnull.

Definition at line 361 of file NullabilityChecker.cpp.

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

Referenced by checkParamsForPreconditionViolation(), and checkSelfIvarsForInvariantViolation().

◆ getNullabilityAnnotation()

static Nullability getNullabilityAnnotation ( QualType  Type)
static

◆ 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 1041 of file NullabilityChecker.cpp.

References clang::ento::CheckerContext::getASTContext(), and clang::ASTContext::getLangOpts().

◆ 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 538 of file NullabilityChecker.cpp.

◆ 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 1017 of file NullabilityChecker.cpp.

◆ REGISTER_MAP_WITH_PROGRAMSTATE()

REGISTER_MAP_WITH_PROGRAMSTATE ( NullabilityMap  ,
const MemRegion ,
NullabilityState   
)

Definition at line 247 of file NullabilityChecker.cpp.