24class UndefinedAssignmentChecker
26 const BugType BT{
this,
"Assigned value is garbage or undefined"};
34void UndefinedAssignmentChecker::checkBind(
SVal location,
SVal val,
43 dyn_cast<FunctionDecl>(
C.getStackFrame()->getDecl()))
44 if (
C.getCalleeName(EnclosingFunctionDecl) ==
"swap")
54 llvm::raw_svector_ostream OS(Str);
56 const Expr *ex =
nullptr;
60 OS <<
"The expression is an uninitialized value. "
61 "The computed value will also be garbage";
68 if (B->isCompoundAssignmentOp()) {
69 if (
C.getSVal(B->getLHS()).isUndef()) {
70 OS <<
"The left expression of the compound assignment is an "
71 "uninitialized value. The computed value will also be garbage";
81 if (
const DeclStmt *DS = dyn_cast<DeclStmt>(StoreE)) {
82 const VarDecl *VD = cast<VarDecl>(DS->getSingleDecl());
87 dyn_cast<CXXConstructorDecl>(
C.getStackFrame()->getDecl())) {
88 if (CD->isImplicit()) {
89 for (
auto *I : CD->inits()) {
90 if (I->getInit()->IgnoreImpCasts() == StoreE) {
91 OS <<
"Value assigned to field '" << I->getMember()->getName()
92 <<
"' in implicit constructor is garbage or undefined";
102 if (OS.str().empty())
103 OS << BT.getDescription();
105 auto R = std::make_unique<PathSensitiveBugReport>(BT, OS.str(), N);
110 C.emitReport(std::move(R));
113void ento::registerUndefinedAssignmentChecker(
CheckerManager &mgr) {
117bool ento::shouldRegisterUndefinedAssignmentChecker(
const CheckerManager &mgr) {
A builtin binary operation expression such as "x + y" or "x <= y".
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
This represents one expression.
Represents a function declaration or definition.
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a variable declaration or definition.
const Expr * getInit() const
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
bool trackExpressionValue(const ExplodedNode *N, const Expr *E, PathSensitiveBugReport &R, TrackingOptions Opts={})
Attempts to add visitors to track expression value back to its point of origin.
The JSON file list parser is used to communicate input to InstallAPI.