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";
101 llvm_unreachable(
"Unknown ProgramPoint kind");
115 if (
const auto *
T = B->getTerminatorStmt()) {
116 return T->getBeginLoc();
132 return S->getBeginLoc();
136 return Init->getSourceLocation();
140 return S->getBeginLoc();
144 return S->getBeginLoc();
150 B && B->getTerminatorStmt())
151 return B->getTerminatorStmt()->getBeginLoc();
159 return S->getBeginLoc();
164 llvm_unreachable(
"Unknown ProgramPoint kind");
172 const bool AddQuotes =
true;
174 Out <<
"\"kind\": \"";
177 Out <<
"BlockEntrance\""
178 <<
", \"block_id\": "
184 Out <<
"FunctionExit\""
185 <<
", \"block_id\": " << FEP->getBlock()->getBlockID()
186 <<
", \"stmt_id\": ";
189 Out << RS->getID(Context) <<
", \"stmt\": ";
190 RS->printJson(Out,
nullptr, PP, AddQuotes);
192 Out <<
"null, \"stmt\": null";
197 llvm_unreachable(
"BlockExitKind");
200 Out <<
"CallEnter\", \"callee_decl\": \"";
206 Out <<
"CallExitBegin\"";
209 Out <<
"CallExitEnd\"";
212 Out <<
"EpsilonPoint\"";
216 Out <<
"LoopExit\", \"stmt\": \""
222 Out <<
"PreCall\", \"decl\": \""
224 <<
"\", \"location\": ";
231 Out <<
"PostCall\", \"decl\": \""
233 <<
"\", \"location\": ";
239 Out <<
"PostInitializer\", ";
242 Out <<
"\"field_decl\": \"" << *FD <<
'\"';
244 Out <<
"\"type\": \"";
247 Ty.
print(Out, Context.getLangOpts());
260 Out <<
"null, \"term_kind\": null";
266 Out <<
", \"location\": ";
269 Out <<
", \"term_kind\": \"";
271 Out <<
"SwitchStmt\", \"case\": ";
273 if (
const auto *
C = dyn_cast<CaseStmt>(Label)) {
274 Out <<
"{ \"lhs\": ";
275 if (
const Stmt *LHS =
C->getLHS()) {
276 LHS->printJson(Out,
nullptr, PP, AddQuotes);
281 Out <<
", \"rhs\": ";
282 if (
const Stmt *RHS =
C->getRHS()) {
283 RHS->printJson(Out,
nullptr, PP, AddQuotes);
290 Out <<
"\"default\"";
293 Out <<
"\"implicit default\"";
297 Out <<
"IndirectGotoStmt\"";
299 Out <<
"Condition\", \"value\": "
300 << (*E.
getSrc()->succ_begin() == E.
getDst() ?
"true" :
"false");
307 assert(S !=
nullptr &&
"Expecting non-null Stmt");
310 <<
"\", \"stmt_id\": " << S->
getID(Context)
311 <<
", \"pointer\": \"" << (
const void *)S <<
"\", ";
312 if (
const auto *CS = dyn_cast<CastExpr>(S))
313 Out <<
"\"cast_kind\": \"" << CS->getCastKindName() <<
"\", ";
315 Out <<
"\"pretty\": ";
317 S->
printJson(Out,
nullptr, PP, AddQuotes);
319 Out <<
", \"location\": ";
322 Out <<
", \"stmt_point_kind\": \"";
328 Out <<
"PostAllocatorCall";
330 Out <<
"PostCondition";
340 Out <<
"PostStmtPurgeDeadSymbols";
342 Out <<
"PreStmtPurgeDeadSymbols";
346 Out <<
"\nKind: '" <<
getKind();
347 llvm_unreachable(
"' is unhandled StmtPoint kind!");
358 : 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
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() 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 LocationContext *LC, 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
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
const LocationContext * getLocationContext() const
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.
Stmt - This represents one statement.
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
const char * getStmtClassName() const
int64_t getID(const ASTContext &Context) const
SourceLocation getBeginLoc() const LLVM_READONLY
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)
const FunctionProtoType * T
Describes how types, statements, expressions, and declarations should be printed.