17 using namespace clang;
26 llvm_unreachable(
"Unhandled ProgramPoint kind");
47 return printJson(llvm::errs());
52 getLocationContext()->getAnalysisDeclContext()->getASTContext();
55 const bool AddQuotes =
true;
57 Out <<
"\"kind\": \"";
60 Out <<
"BlockEntrance\"" 62 << castAs<BlockEntrance>().getBlock()->getBlockID();
66 auto FEP = getAs<FunctionExitPoint>();
67 Out <<
"FunctionExit\"" 68 <<
", \"block_id\": " << FEP->getBlock()->getBlockID()
72 Out << RS->getID(Context) <<
", \"stmt\": ";
73 RS->printJson(Out,
nullptr, PP, AddQuotes);
75 Out <<
"null, \"stmt\": null";
80 llvm_unreachable(
"BlockExitKind");
86 Out <<
"CallExitBegin\"";
89 Out <<
"CallExitEnd\"";
92 Out <<
"EpsilonPoint\"";
96 Out <<
"LoopExit\", \"stmt\": \"" 97 << castAs<LoopExit>().getLoopStmt()->getStmtClassName() <<
'\"';
102 Out <<
"PreCall\", \"decl\": \"" 104 <<
"\", \"location\": ";
111 Out <<
"PostCall\", \"decl\": \"" 113 <<
"\", \"location\": ";
119 Out <<
"PostInitializer\", ";
122 Out <<
"\"field_decl\": \"" << *FD <<
'\"';
124 Out <<
"\"type\": \"";
134 const BlockEdge &E = castAs<BlockEdge>();
140 Out <<
"null, \"term_kind\": null";
146 Out <<
", \"location\": ";
149 Out <<
", \"term_kind\": \"";
150 if (isa<SwitchStmt>(T)) {
151 Out <<
"SwitchStmt\", \"case\": ";
153 if (
const auto *
C = dyn_cast<CaseStmt>(
Label)) {
154 Out <<
"{ \"lhs\": ";
155 if (
const Stmt *LHS =
C->getLHS()) {
156 LHS->printJson(Out,
nullptr, PP, AddQuotes);
161 Out <<
", \"rhs\": ";
162 if (
const Stmt *RHS =
C->getRHS()) {
163 RHS->printJson(Out,
nullptr, PP, AddQuotes);
169 assert(isa<DefaultStmt>(
Label));
170 Out <<
"\"default\"";
173 Out <<
"\"implicit default\"";
175 }
else if (isa<IndirectGotoStmt>(T)) {
177 Out <<
"IndirectGotoStmt\"";
179 Out <<
"Condition\", \"value\": " 186 const Stmt *S = castAs<StmtPoint>().getStmt();
187 assert(S !=
nullptr &&
"Expecting non-null Stmt");
190 <<
"\", \"stmt_id\": " << S->
getID(Context)
191 <<
", \"pointer\": \"" << (
const void *)S <<
"\", \"pretty\": ";
193 S->
printJson(Out,
nullptr, PP, AddQuotes);
195 Out <<
", \"location\": ";
198 Out <<
", \"stmt_point_kind\": \"";
199 if (getAs<PreLoad>())
201 else if (getAs<PreStore>())
203 else if (getAs<PostAllocatorCall>())
204 Out <<
"PostAllocatorCall";
205 else if (getAs<PostCondition>())
206 Out <<
"PostCondition";
207 else if (getAs<PostLoad>())
209 else if (getAs<PostLValue>())
211 else if (getAs<PostStore>())
213 else if (getAs<PostStmt>())
215 else if (getAs<PostStmtPurgeDeadSymbols>())
216 Out <<
"PostStmtPurgeDeadSymbols";
217 else if (getAs<PreStmtPurgeDeadSymbols>())
218 Out <<
"PreStmtPurgeDeadSymbols";
219 else if (getAs<PreStmt>())
222 Out <<
"\nKind: '" <<
getKind();
223 llvm_unreachable(
"' is unhandled StmtPoint kind!");
234 : Desc((MsgProvider +
" : " + Msg).str()) {}
A (possibly-)qualified type.
succ_iterator succ_begin()
Stmt - This represents one statement.
unsigned getBlockID() const
const CFGBlock * getSrc() const
Represents a point after we ran remove dead bindings BEFORE processing the given statement.
Represents an implicit call event.
Describes how types, statements, expressions, and declarations should be printed. ...
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
void printTerminatorJson(raw_ostream &Out, const LangOptions &LO, bool AddQuotes) const
printTerminatorJson - Pretty-prints the terminator in JSON format.
const char * getStmtClassName() const
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const LocationContext *LC, const ProgramPointTag *tag)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a member of a struct/union/class.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
LLVM_DUMP_METHOD void dump() const
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg)
SourceLocation getLocation() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
StringRef getTagDescription() const override
const clang::PrintingPolicy & getPrintingPolicy() const
void printJson(llvm::raw_ostream &Out, const char *NL="\) const
Represents a point after we ran remove dead bindings AFTER processing the given statement.
FieldDecl * getAnyMember() const
const CFGBlock * getDst() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ProgramPoints can be "tagged" as representing points specific to a given analysis entity...
int64_t getID(const ASTContext &Context) const
void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc, const SourceManager &SM, bool AddBraces=true)
const Decl * getDecl() const
Dataflow Directional Tag Classes.
Stmt * getTerminatorStmt()
Represents a C++ base or member initializer.
SourceManager & getSourceManager()
std::string getQualifiedNameAsString() const
static Decl::Kind getKind(const Decl *D)
virtual ~ProgramPointTag()
const LangOptions & getLangOpts() const
This class handles loading and caching of source files into memory.
QualType getType() const
Return the type wrapped by this type source info.