27 llvm_unreachable(
"Unhandled ProgramPoint kind");
56 const bool AddQuotes =
true;
58 Out <<
"\"kind\": \"";
61 Out <<
"BlockEntrance\""
63 << castAs<BlockEntrance>().getBlock()->getBlockID();
67 auto FEP = getAs<FunctionExitPoint>();
68 Out <<
"FunctionExit\""
69 <<
", \"block_id\": " << FEP->getBlock()->getBlockID()
73 Out << RS->getID(Context) <<
", \"stmt\": ";
74 RS->printJson(Out,
nullptr, PP, AddQuotes);
76 Out <<
"null, \"stmt\": null";
81 llvm_unreachable(
"BlockExitKind");
87 Out <<
"CallExitBegin\"";
90 Out <<
"CallExitEnd\"";
93 Out <<
"EpsilonPoint\"";
97 Out <<
"LoopExit\", \"stmt\": \""
98 << castAs<LoopExit>().getLoopStmt()->getStmtClassName() <<
'\"';
103 Out <<
"PreCall\", \"decl\": \""
105 <<
"\", \"location\": ";
112 Out <<
"PostCall\", \"decl\": \""
114 <<
"\", \"location\": ";
120 Out <<
"PostInitializer\", ";
123 Out <<
"\"field_decl\": \"" << *FD <<
'\"';
125 Out <<
"\"type\": \"";
136 const Stmt *
T =
E.getSrc()->getTerminatorStmt();
137 Out <<
"Edge\", \"src_id\": " <<
E.getSrc()->getBlockID()
138 <<
", \"dst_id\": " <<
E.getDst()->getBlockID() <<
", \"terminator\": ";
141 Out <<
"null, \"term_kind\": null";
145 E.getSrc()->printTerminatorJson(Out, Context.
getLangOpts(),
147 Out <<
", \"location\": ";
150 Out <<
", \"term_kind\": \"";
151 if (isa<SwitchStmt>(
T)) {
152 Out <<
"SwitchStmt\", \"case\": ";
153 if (
const Stmt *
Label =
E.getDst()->getLabel()) {
154 if (
const auto *
C = dyn_cast<CaseStmt>(
Label)) {
155 Out <<
"{ \"lhs\": ";
156 if (
const Stmt *LHS =
C->getLHS()) {
157 LHS->printJson(Out,
nullptr, PP, AddQuotes);
162 Out <<
", \"rhs\": ";
163 if (
const Stmt *RHS =
C->getRHS()) {
164 RHS->printJson(Out,
nullptr, PP, AddQuotes);
170 assert(isa<DefaultStmt>(
Label));
171 Out <<
"\"default\"";
174 Out <<
"\"implicit default\"";
176 }
else if (isa<IndirectGotoStmt>(
T)) {
178 Out <<
"IndirectGotoStmt\"";
180 Out <<
"Condition\", \"value\": "
181 << (*
E.getSrc()->succ_begin() ==
E.getDst() ?
"true" :
"false");
187 const Stmt *S = castAs<StmtPoint>().getStmt();
188 assert(S !=
nullptr &&
"Expecting non-null Stmt");
190 Out <<
"Statement\", \"stmt_kind\": \"" << S->getStmtClassName()
191 <<
"\", \"stmt_id\": " << S->getID(Context)
192 <<
", \"pointer\": \"" << (
const void *)S <<
"\", ";
193 if (
const auto *CS = dyn_cast<CastExpr>(S))
194 Out <<
"\"cast_kind\": \"" << CS->getCastKindName() <<
"\", ";
196 Out <<
"\"pretty\": ";
198 S->printJson(Out,
nullptr, PP, AddQuotes);
200 Out <<
", \"location\": ";
203 Out <<
", \"stmt_point_kind\": \"";
204 if (getAs<PreLoad>())
206 else if (getAs<PreStore>())
208 else if (getAs<PostAllocatorCall>())
209 Out <<
"PostAllocatorCall";
210 else if (getAs<PostCondition>())
211 Out <<
"PostCondition";
212 else if (getAs<PostLoad>())
214 else if (getAs<PostLValue>())
216 else if (getAs<PostStore>())
218 else if (getAs<PostStmt>())
220 else if (getAs<PostStmtPurgeDeadSymbols>())
221 Out <<
"PostStmtPurgeDeadSymbols";
222 else if (getAs<PreStmtPurgeDeadSymbols>())
223 Out <<
"PreStmtPurgeDeadSymbols";
224 else if (getAs<PreStmt>())
227 Out <<
"\nKind: '" <<
getKind();
228 llvm_unreachable(
"' is unhandled StmtPoint kind!");
239 : Desc((MsgProvider +
" : " + Msg).str()) {}
Defines the clang::ASTContext interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
const LangOptions & getLangOpts() const
const clang::PrintingPolicy & getPrintingPolicy() const
ASTContext & getASTContext() 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()
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const LocationContext *LC, const ProgramPointTag *tag)
LLVM_DUMP_METHOD void dump() const
void printJson(llvm::raw_ostream &Out, const char *NL="\n") const
@ PreStmtPurgeDeadSymbolsKind
@ PostStmtPurgeDeadSymbolsKind
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;.
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg)
StringRef getTagDescription() const override
This class handles loading and caching of source files into memory.
Stmt - This represents one statement.
The JSON file list parser is used to communicate input to InstallAPI.
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.