27#include "llvm/ADT/ImmutableMap.h"
28#include "llvm/ADT/SmallPtrSet.h"
29#include "llvm/Support/ErrorHandling.h"
30#include "llvm/Support/raw_ostream.h"
40 case Stmt::OpaqueValueExprClass:
46 case Stmt::ExprWithCleanupsClass:
49 case Stmt::ConstantExprClass:
52 case Stmt::CXXBindTemporaryExprClass:
55 case Stmt::SubstNonTypeTemplateParmExprClass:
71 const SVal*
X = ExprBindings.lookup(E);
85 case Stmt::CXXBindTemporaryExprClass:
86 case Stmt::ExprWithCleanupsClass:
87 case Stmt::GenericSelectionExprClass:
88 case Stmt::ConstantExprClass:
89 case Stmt::ParenExprClass:
90 case Stmt::SubstNonTypeTemplateParmExprClass:
91 llvm_unreachable(
"Should have been handled by ignoreTransparentExprs");
93 case Stmt::AddrLabelExprClass:
94 case Stmt::CharacterLiteralClass:
95 case Stmt::CXXBoolLiteralExprClass:
96 case Stmt::CXXScalarValueInitExprClass:
97 case Stmt::ImplicitValueInitExprClass:
98 case Stmt::IntegerLiteralClass:
99 case Stmt::ObjCBoolLiteralExprClass:
100 case Stmt::CXXNullPtrLiteralExprClass:
101 case Stmt::ObjCStringLiteralClass:
102 case Stmt::StringLiteralClass:
103 case Stmt::TypeTraitExprClass:
104 case Stmt::SizeOfPackExprClass:
105 case Stmt::PredefinedExprClass:
134 MarkLiveCallback(
SymbolReaper &symreaper) : SymReaper(symreaper) {}
136 bool VisitSymbol(
SymbolRef sym)
override {
137 SymReaper.markLive(sym);
141 bool VisitMemRegion(
const MemRegion *R)
override {
142 SymReaper.markLive(R);
165 MarkLiveCallback CB(SymReaper);
168 llvm::ImmutableMapRef<EnvironmentEntry, SVal>
169 EBMapRef(NewEnv.ExprBindings.getRootWithoutRetain(),
175 SVal X = I.getData();
179 EBMapRef = EBMapRef.add(BlkExpr,
X);
186 NewEnv.ExprBindings = EBMapRef.asImmutableMap();
192 unsigned int Space,
bool IsDot)
const {
193 Indent(Out, Space, IsDot) <<
"\"environment\": ";
195 if (ExprBindings.isEmpty()) {
196 Out <<
"null," << NL;
204 for (
const auto &I : *
this) {
206 if (FoundContexts.count(LC) == 0) {
210 FoundContexts.insert(LCI);
217 Out <<
"{ \"pointer\": \"" << (
const void *)LCtx->
getStackFrame()
218 <<
"\", \"items\": [" << NL;
223 bool HasItem =
false;
224 unsigned int InnerSpace = Space + 1;
227 BindingsTy::iterator LastI = ExprBindings.end();
228 for (BindingsTy::iterator I = ExprBindings.begin(); I != ExprBindings.end();
230 if (I->first.getLocationContext() != LC)
238 const Expr *Ex = I->first.getExpr();
240 assert(Ex !=
nullptr &&
"Expected non-null Expr");
245 for (BindingsTy::iterator I = ExprBindings.begin(); I != ExprBindings.end();
247 if (I->first.getLocationContext() != LC)
250 const Expr *Ex = I->first.getExpr();
251 Indent(Out, InnerSpace, IsDot)
252 <<
"{ \"stmt_id\": " << Ex->
getID(Ctx) <<
", \"kind\": \""
256 Out <<
", \"value\": ";
257 I->second.printJson(Out,
true);
267 Indent(Out, --InnerSpace, IsDot) <<
']';
272 Indent(Out, --Space, IsDot) <<
"]}," << NL;
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
static const Expr * ignoreTransparentExprs(const Expr *E)
Defines the clang::Expr interface and subclasses for C++ expressions.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the Objective-C statement AST node classes.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const clang::PrintingPolicy & getPrintingPolicy() const
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
const LocationContext * getParent() const
It might return null.
const StackFrame * getStackFrame() const
void printJson(raw_ostream &Out, const char *NL="\n", unsigned int Space=0, bool IsDot=false, std::function< void(const LocationContext *)> printMoreInfoPerContext=[](const LocationContext *) {}) const
Prints out the call stack in json format.
It represents a stack frame of the call stack (based on CallEvent).
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
StmtClass getStmtClass() const
const char * getStmtClassName() const
int64_t getID(const ASTContext &Context) const
An entry in the environment consists of a Stmt and an LocationContext.
const Expr * getExpr() const
const LocationContext * getLocationContext() const
EnvironmentEntry(const Expr *E, const LocationContext *L)
Environment getInitialEnvironment()
Environment bindExpr(Environment Env, const EnvironmentEntry &E, SVal V, bool Invalidate)
Bind a symbolic value to the given environment entry.
Environment removeDeadBindings(Environment Env, SymbolReaper &SymReaper, ProgramStateRef state)
An immutable map from EnvironmentEntries to SVals.
SVal getSVal(const EnvironmentEntry &E, SValBuilder &svalBuilder) const
Fetches the current binding of the expression in the Environment.
void printJson(raw_ostream &Out, const ASTContext &Ctx, const LocationContext *LCtx=nullptr, const char *NL="\n", unsigned int Space=0, bool IsDot=false) const
BindingsTy::iterator iterator
MemRegion - The root abstract class for all memory regions.
std::optional< SVal > getConstantVal(const Expr *E)
Returns the value of E, if it can be determined in a non-path-sensitive manner.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
A utility class that visits the reachable symbols using a custom SymbolVisitor.
bool scan(nonloc::LazyCompoundVal val)
A class responsible for cleaning up unused symbols.
bool isLive(SymbolRef sym)
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const SymExpr * SymbolRef
The JSON file list parser is used to communicate input to InstallAPI.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
U cast(CodeGen::Address addr)
Describes how types, statements, expressions, and declarations should be printed.