28 llvm_unreachable(
"Unhandled ProgramPoint kind");
57 return "BlockEntrance";
63 return "PreStmtPurgeDeadSymbols";
65 return "PostStmtPurgeDeadSymbols";
77 return "PostCondition";
81 return "PostAllocatorCall";
83 return "PostInitializer";
87 return "CallExitBegin";
91 return "FunctionExit";
93 return "PreImplicitCall";
95 return "PostImplicitCall";
103 llvm_unreachable(
"Unknown ProgramPoint kind");
117 if (
const auto *T = B->getTerminatorStmt()) {
118 return T->getBeginLoc();
134 return S->getBeginLoc();
138 return Init->getSourceLocation();
142 return S->getBeginLoc();
146 return S->getBeginLoc();
152 B && B->getTerminatorStmt())
153 return B->getTerminatorStmt()->getBeginLoc();
161 return S->getBeginLoc();
165 return S->getBeginLoc();
170 llvm_unreachable(
"Unknown ProgramPoint kind");
178 const bool AddQuotes =
true;
180 Out <<
"\"kind\": \"";
183 Out <<
"BlockEntrance\""
184 <<
", \"block_id\": "
190 Out <<
"FunctionExit\""
191 <<
", \"block_id\": " << FEP->getBlock()->getBlockID()
192 <<
", \"stmt_id\": ";
195 Out << RS->getID(Context) <<
", \"stmt\": ";
196 RS->printJson(Out,
nullptr, PP, AddQuotes);
198 Out <<
"null, \"stmt\": null";
203 llvm_unreachable(
"BlockExitKind");
206 Out <<
"CallEnter\", \"callee_decl\": \"";
212 Out <<
"CallExitBegin\"";
215 Out <<
"CallExitEnd\"";
218 Out <<
"EpsilonPoint\"";
222 Out <<
"LoopExit\", \"stmt\": \""
227 Out <<
"LifetimeEnd\", \"var\": \""
233 Out <<
"PreCall\", \"decl\": \""
235 <<
"\", \"location\": ";
242 Out <<
"PostCall\", \"decl\": \""
244 <<
"\", \"location\": ";
250 Out <<
"PostInitializer\", ";
253 Out <<
"\"field_decl\": \"" << *FD <<
'\"';
255 Out <<
"\"type\": \"";
258 Ty.
print(Out, Context.getLangOpts());
271 Out <<
"null, \"term_kind\": null";
277 Out <<
", \"location\": ";
280 Out <<
", \"term_kind\": \"";
282 Out <<
"SwitchStmt\", \"case\": ";
284 if (
const auto *
C = dyn_cast<CaseStmt>(Label)) {
285 Out <<
"{ \"lhs\": ";
286 if (
const Stmt *LHS =
C->getLHS()) {
287 LHS->printJson(Out,
nullptr, PP, AddQuotes);
292 Out <<
", \"rhs\": ";
293 if (
const Stmt *RHS =
C->getRHS()) {
294 RHS->printJson(Out,
nullptr, PP, AddQuotes);
301 Out <<
"\"default\"";
304 Out <<
"\"implicit default\"";
308 Out <<
"IndirectGotoStmt\"";
310 Out <<
"Condition\", \"value\": "
311 << (*E.
getSrc()->succ_begin() == E.
getDst() ?
"true" :
"false");
318 assert(S !=
nullptr &&
"Expecting non-null Stmt");
320 Out <<
"Statement\", \"stmt_kind\": \"" << S->getStmtClassName()
321 <<
"\", \"stmt_id\": " << S->getID(Context)
322 <<
", \"pointer\": \"" << (
const void *)S <<
"\", ";
323 if (
const auto *CS = dyn_cast<CastExpr>(S))
324 Out <<
"\"cast_kind\": \"" << CS->getCastKindName() <<
"\", ";
326 Out <<
"\"pretty\": ";
328 S->printJson(Out,
nullptr, PP, AddQuotes);
330 Out <<
", \"location\": ";
333 Out <<
", \"stmt_point_kind\": \"";
339 Out <<
"PostAllocatorCall";
341 Out <<
"PostCondition";
351 Out <<
"PostStmtPurgeDeadSymbols";
353 Out <<
"PreStmtPurgeDeadSymbols";
357 Out <<
"\nKind: '" <<
getKind();
358 llvm_unreachable(
"' is unhandled StmtPoint kind!");
369 : Desc((MsgProvider +
" : " + Msg).str()) {}
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static std::string getFunctionName(const Decl *D)
ASTContext & getASTContext() const
const CFGBlock * getSrc() const
const CFGBlock * getDst() const
void printTerminatorJson(raw_ostream &Out, const LangOptions &LO, bool AddQuotes) const
printTerminatorJson - Pretty-prints the terminator in JSON format.
Stmt * getTerminatorStmt()
unsigned getBlockID() const
Represents a C++ base or member initializer.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Represents a member of a struct/union/class.
Represents an implicit call event.
SourceLocation getLocation() const
const Decl * getDecl() const
std::string getQualifiedNameAsString() const
Represents a point after we ran remove dead bindings AFTER processing the given statement.
Represents a point after we ran remove dead bindings BEFORE processing the given statement.
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
virtual ~ProgramPointTag()
T castAs() const
Convert to the specified ProgramPoint type, asserting that this ProgramPoint is of the desired type.
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const StackFrame *SF, const ProgramPointTag *tag)
static StringRef getProgramPointKindName(Kind K)
LLVM_DUMP_METHOD void dump() const
std::optional< SourceLocation > getSourceLocation() const
void printJson(llvm::raw_ostream &Out, const char *NL="\n") const
@ PreStmtPurgeDeadSymbolsKind
@ PostStmtPurgeDeadSymbolsKind
const StackFrame * getStackFrame() const
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
A (possibly-)qualified type.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
StringRef getDebugTag() const override
The description of this program point which will be dumped for debugging purposes.
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg)
This class handles loading and caching of source files into memory.
It represents a stack frame of the call stack.
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
Stmt - This represents one statement.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc, const SourceManager &SM, bool AddBraces=true)
Describes how types, statements, expressions, and declarations should be printed.