21 using namespace clang;
25 class UndefinedAssignmentChecker
27 mutable std::unique_ptr<BugType> BT;
35 void UndefinedAssignmentChecker::checkBind(
SVal location,
SVal val,
54 const char *str =
"Assigned value is garbage or undefined";
60 const Expr *ex =
nullptr;
63 if (
const UnaryOperator *U = dyn_cast<UnaryOperator>(StoreE)) {
64 str =
"The expression is an uninitialized value. " 65 "The computed value will also be garbage";
72 if (B->isCompoundAssignmentOp()) {
75 str =
"The left expression of the compound assignment is an " 76 "uninitialized value. The computed value will also be garbage";
86 if (
const DeclStmt *DS = dyn_cast<DeclStmt>(StoreE)) {
94 auto R = llvm::make_unique<BugReport>(*BT, str, N);
102 void ento::registerUndefinedAssignmentChecker(
CheckerManager &mgr) {
An instance of this class is created to represent a function declaration or definition.
ExplodedNode * generateErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
Stmt - This represents one statement.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
StringRef getCalleeName(const FunctionDecl *FunDecl) const
Get the name of the called function (path-sensitive).
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
A builtin binary operation expression such as "x + y" or "x <= y".
Expr - This represents one expression.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
CHECKER * registerChecker()
Used to register checkers.
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
Dataflow Directional Tag Classes.
const Expr * getInit() const
const Decl * getDecl() const
const StackFrameContext * getStackFrame() const
const ProgramStateRef & getState() const
bool trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S, BugReport &R, bool IsArg=false, bool EnableNullFPSuppression=true)
Attempts to add visitors to trace a null or undefined value back to its point of origin, whether it is a symbol constrained to null or an explicit assignment.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const LocationContext * getLocationContext() const