19 #include "llvm/Support/raw_ostream.h"
21 using namespace clang;
27 switch (E->getStmtClass()) {
28 case Stmt::OpaqueValueExprClass:
29 E = cast<OpaqueValueExpr>(
E)->getSourceExpr();
31 case Stmt::ExprWithCleanupsClass:
32 E = cast<ExprWithCleanups>(
E)->getSubExpr();
34 case Stmt::CXXBindTemporaryExprClass:
35 E = cast<CXXBindTemporaryExpr>(
E)->getSubExpr();
37 case Stmt::SubstNonTypeTemplateParmExprClass:
38 E = cast<SubstNonTypeTemplateParmExpr>(
E)->getReplacement();
49 if (
const Expr *
E = dyn_cast<Expr>(S))
55 : std::pair<const
Stmt *,
57 L ? L->getCurrentStackFrame()
61 const SVal*
X = ExprBindings.lookup(E);
74 switch (S->getStmtClass()) {
75 case Stmt::CXXBindTemporaryExprClass:
76 case Stmt::ExprWithCleanupsClass:
77 case Stmt::GenericSelectionExprClass:
78 case Stmt::OpaqueValueExprClass:
79 case Stmt::ParenExprClass:
80 case Stmt::SubstNonTypeTemplateParmExprClass:
81 llvm_unreachable(
"Should have been handled by ignoreTransparentExprs");
83 case Stmt::AddrLabelExprClass:
84 case Stmt::CharacterLiteralClass:
85 case Stmt::CXXBoolLiteralExprClass:
86 case Stmt::CXXScalarValueInitExprClass:
87 case Stmt::ImplicitValueInitExprClass:
88 case Stmt::IntegerLiteralClass:
89 case Stmt::ObjCBoolLiteralExprClass:
90 case Stmt::CXXNullPtrLiteralExprClass:
91 case Stmt::ObjCStringLiteralClass:
92 case Stmt::StringLiteralClass:
93 case Stmt::TypeTraitExprClass:
97 case Stmt::ReturnStmtClass: {
127 MarkLiveCallback(
SymbolReaper &symreaper) : SymReaper(symreaper) {}
128 bool VisitSymbol(
SymbolRef sym)
override {
129 SymReaper.markLive(sym);
132 bool VisitMemRegion(
const MemRegion *R)
override {
133 SymReaper.markLive(R);
156 MarkLiveCallback CB(SymReaper);
159 llvm::ImmutableMapRef<EnvironmentEntry,SVal>
160 EBMapRef(NewEnv.ExprBindings.getRootWithoutRetain(),
168 const SVal &X =
I.getData();
172 EBMapRef = EBMapRef.add(BlkExpr, X);
179 for (; SI != SE; ++SI)
184 NewEnv.ExprBindings = EBMapRef.asImmutableMap();
189 const char *Sep)
const {
205 assert(S !=
nullptr &&
"Expected non-null Stmt");
208 << (
const void*) S <<
") ";
211 Out <<
" : " <<
I.getData();
EnvironmentEntry(const Stmt *s, const LocationContext *L)
MemRegion - The root abstract class for all memory regions.
void print(raw_ostream &Out, const char *NL, const char *Sep) const
bool maybeDead(SymbolRef sym)
If a symbol is known to be live, marks the symbol as live.
A Utility class that allows to visit the reachable symbols using a custom SymbolVisitor.
Describes how types, statements, expressions, and declarations should be printed. ...
Defines the clang::Expr interface and subclasses for C++ expressions.
SVal getSVal(const EnvironmentEntry &E, SValBuilder &svalBuilder) const
Fetches the current binding of the expression in the Environment.
Environment bindExpr(Environment Env, const EnvironmentEntry &E, SVal V, bool Invalidate)
Bind a symbolic value to the given environment entry.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static const Expr * ignoreTransparentExprs(const Expr *E)
BindingsTy::iterator iterator
SymExpr::symbol_iterator symbol_begin() const
detail::InMemoryDirectory::const_iterator I
Expr - This represents one expression.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
const Stmt * getStmt() const
bool scan(nonloc::LazyCompoundVal val)
Environment getInitialEnvironment()
An entry in the environment consists of a Stmt and an LocationContext.
SymExpr::symbol_iterator symbol_end() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
A class responsible for cleaning up unused symbols.
An immutable map from EnvironemntEntries to SVals.
const LocationContext * getLocationContext() const
detail::InMemoryDirectory::const_iterator E
const Expr * getRetValue() const
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Optional< SVal > getConstantVal(const Expr *E)
Returns the value of E, if it can be determined in a non-path-sensitive manner.
Environment removeDeadBindings(Environment Env, SymbolReaper &SymReaper, ProgramStateRef state)
bool isLive(SymbolRef sym)
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Iterator over symbols that the current symbol depends on.