23#include "llvm/Support/Process.h"
33class DominatorsTreeDumper :
public Checker<check::ASTCodeBody> {
35 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
36 BugReporter &BR)
const {
50bool ento::shouldRegisterDominatorsTreeDumper(
const CheckerManager &mgr) {
59class PostDominatorsTreeDumper :
public Checker<check::ASTCodeBody> {
61 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
62 BugReporter &BR)
const {
76bool ento::shouldRegisterPostDominatorsTreeDumper(
const CheckerManager &mgr) {
85class ControlDependencyTreeDumper :
public Checker<check::ASTCodeBody> {
87 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
88 BugReporter &BR)
const {
90 ControlDependencyCalculator Dom(AC->getCFG());
97void ento::registerControlDependencyTreeDumper(
CheckerManager &mgr) {
101bool ento::shouldRegisterControlDependencyTreeDumper(
const CheckerManager &mgr) {
110class LiveVariablesDumper :
public Checker<check::ASTCodeBody> {
112 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
113 BugReporter &BR)
const {
114 if (LiveVariables* L = mgr.
getAnalysis<LiveVariables>(D)) {
125bool ento::shouldRegisterLiveVariablesDumper(
const CheckerManager &mgr) {
134class LiveExpressionsDumper :
public Checker<check::ASTCodeBody> {
136 void checkASTCodeBody(
const Decl *D, AnalysisManager& Mgr,
137 BugReporter &BR)
const {
138 if (LiveVariables *L = Mgr.
getAnalysis<RelaxedLiveVariables>(D))
148bool ento::shouldRegisterLiveExpressionsDumper(
const CheckerManager &mgr) {
157class CFGViewer :
public Checker<check::ASTCodeBody> {
159 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
160 BugReporter &BR)
const {
161 if (CFG *cfg = mgr.
getCFG(D)) {
181class CFGDumper :
public Checker<check::ASTCodeBody> {
183 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
184 BugReporter &BR)
const {
186 Policy.TerseOutput =
true;
187 Policy.PolishForDeclaration =
true;
188 D->
print(llvm::errs(), Policy);
190 if (CFG *cfg = mgr.
getCFG(D)) {
192 llvm::sys::Process::StandardErrHasColors());
211class CallGraphViewer :
public Checker< check::ASTDecl<TranslationUnitDecl> > {
213 void checkASTDecl(
const TranslationUnitDecl *TU, AnalysisManager& mgr,
214 BugReporter &BR)
const {
226bool ento::shouldRegisterCallGraphViewer(
const CheckerManager &mgr) {
235class CallGraphDumper :
public Checker< check::ASTDecl<TranslationUnitDecl> > {
237 void checkASTDecl(
const TranslationUnitDecl *TU, AnalysisManager& mgr,
238 BugReporter &BR)
const {
250bool ento::shouldRegisterCallGraphDumper(
const CheckerManager &mgr) {
259class ConfigDumper :
public Checker< check::EndOfTranslationUnit > {
262 static int compareEntry(
const Table::MapEntryTy *
const *LHS,
263 const Table::MapEntryTy *
const *RHS) {
264 return (*LHS)->getKey().compare((*RHS)->getKey());
268 void checkEndOfTranslationUnit(
const TranslationUnitDecl *TU,
269 AnalysisManager& mgr,
270 BugReporter &BR)
const {
273 SmallVector<const Table::MapEntryTy *, 32> Keys;
274 for (
const auto &Entry : Config)
275 Keys.push_back(&Entry);
276 llvm::array_pod_sort(Keys.begin(), Keys.end(), compareEntry);
278 llvm::errs() <<
"[config]\n";
279 for (
unsigned I = 0, E = Keys.size(); I != E; ++I)
280 llvm::errs() << Keys[I]->getKey() <<
" = "
281 << (Keys[I]->second.empty() ?
"\"\"" : Keys[I]->second)
300class ExplodedGraphViewer :
public Checker< check::EndAnalysis > {
302 ExplodedGraphViewer() {}
303 void checkEndAnalysis(ExplodedGraph &G, BugReporter &B,ExprEngine &Eng)
const {
314bool ento::shouldRegisterExplodedGraphViewer(
const CheckerManager &mgr) {
324class ReportStmts :
public Checker<check::PreStmt<Stmt>> {
325 BugType BT_stmtLoc{
this,
"Statement"};
328 void checkPreStmt(
const Stmt *S, CheckerContext &
C)
const {
329 ExplodedNode *Node =
C.generateNonFatalErrorNode();
334 std::make_unique<PathSensitiveBugReport>(BT_stmtLoc,
"Statement", Node);
336 C.emitReport(std::move(
Report));
ConfigTable Config
A key-value table of use-specified configuration values.
llvm::StringMap< std::string > ConfigTable
void dump()
Dumps immediate dominators for each block.
void buildDominatorTree(CFG *cfg)
Builds the dominator tree for a given CFG.
void addToCallGraph(Decl *D)
Populate the call graph with the functions in the given declaration.
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
const LangOptions & getLangOpts() const
AnalysisDeclContext * getAnalysisDeclContext(const Decl *D)
SourceManager & getSourceManager() override
T * getAnalysis(Decl const *D)
AnalyzerOptions & options
CFG * getCFG(Decl const *D)
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
Simple checker classes that implement one frontend (i.e.
void ViewGraph(bool trim=false)
Visualize the ExplodedGraph created by executing the simulation.
The JSON file list parser is used to communicate input to InstallAPI.
CFGDominatorTreeImpl< true > CFGPostDomTree
CFGDominatorTreeImpl< false > CFGDomTree