#include "clang/AST/DeclTemplate.h"
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h"
#include <optional>
#include <utility>
usingnamespaceclang;
usingnamespaceento;
namespace {
class CastValueChecker : public Checker<check::DeadSymbols, eval::Call> { … };
}
static bool isInfeasibleCast(const DynamicCastInfo *CastInfo,
bool CastSucceeds) { … }
static const NoteTag *getNoteTag(CheckerContext &C,
const DynamicCastInfo *CastInfo,
QualType CastToTy, const Expr *Object,
bool CastSucceeds, bool IsKnownCast) { … }
static const NoteTag *getNoteTag(CheckerContext &C,
SmallVector<QualType, 4> CastToTyVec,
const Expr *Object,
bool IsKnownCast) { … }
static QualType alignReferenceTypes(QualType toAlign, QualType alignTowards,
ASTContext &ACtx) { … }
static void addCastTransition(const CallEvent &Call, DefinedOrUnknownSVal DV,
CheckerContext &C, bool IsNonNullParam,
bool IsNonNullReturn,
bool IsCheckedCast = false) { … }
static void addInstanceOfTransition(const CallEvent &Call,
DefinedOrUnknownSVal DV,
ProgramStateRef State, CheckerContext &C,
bool IsInstanceOf) { … }
static void evalNonNullParamNonNullReturn(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C,
bool IsCheckedCast = false) { … }
static void evalNonNullParamNullReturn(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) { … }
static void evalNullParamNullReturn(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) { … }
void CastValueChecker::evalCast(const CallEvent &Call, DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
void CastValueChecker::evalDynCast(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
void CastValueChecker::evalCastOrNull(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
void CastValueChecker::evalDynCastOrNull(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
static void evalZeroParamNonNullReturn(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C,
bool IsCheckedCast = false) { … }
static void evalZeroParamNullReturn(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) { … }
void CastValueChecker::evalCastAs(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
void CastValueChecker::evalGetAs(const CallEvent &Call, DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
void CastValueChecker::evalIsa(const CallEvent &Call, DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
void CastValueChecker::evalIsaAndNonNull(const CallEvent &Call,
DefinedOrUnknownSVal DV,
CheckerContext &C) const { … }
bool CastValueChecker::evalCall(const CallEvent &Call,
CheckerContext &C) const { … }
void CastValueChecker::checkDeadSymbols(SymbolReaper &SR,
CheckerContext &C) const { … }
void ento::registerCastValueChecker(CheckerManager &Mgr) { … }
bool ento::shouldRegisterCastValueChecker(const CheckerManager &mgr) { … }