24 #include "llvm/Support/Process.h" 26 using namespace clang;
34 class DominatorsTreeDumper :
public Checker<check::ASTCodeBody> {
36 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
37 BugReporter &BR)
const {
47 void ento::registerDominatorsTreeDumper(CheckerManager &mgr) {
48 mgr.registerChecker<DominatorsTreeDumper>();
56 class LiveVariablesDumper :
public Checker<check::ASTCodeBody> {
58 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
59 BugReporter &BR)
const {
61 L->dumpBlockLiveness(mgr.getSourceManager());
67 void ento::registerLiveVariablesDumper(CheckerManager &mgr) {
68 mgr.registerChecker<LiveVariablesDumper>();
76 class LiveStatementsDumper :
public Checker<check::ASTCodeBody> {
78 void checkASTCodeBody(
const Decl *D, AnalysisManager& Mgr,
79 BugReporter &BR)
const {
81 L->dumpStmtLiveness(Mgr.getSourceManager());
86 void ento::registerLiveStatementsDumper(CheckerManager &mgr) {
87 mgr.registerChecker<LiveStatementsDumper>();
95 class CFGViewer :
public Checker<check::ASTCodeBody> {
97 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
98 BugReporter &BR)
const {
99 if (
CFG *cfg = mgr.getCFG(D)) {
100 cfg->viewCFG(mgr.getLangOpts());
106 void ento::registerCFGViewer(CheckerManager &mgr) {
107 mgr.registerChecker<CFGViewer>();
115 class CFGDumper :
public Checker<check::ASTCodeBody> {
117 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
118 BugReporter &BR)
const {
121 Policy.PolishForDeclaration =
true;
122 D->
print(llvm::errs(), Policy);
124 if (
CFG *cfg = mgr.getCFG(D)) {
125 cfg->dump(mgr.getLangOpts(),
126 llvm::sys::Process::StandardErrHasColors());
132 void ento::registerCFGDumper(CheckerManager &mgr) {
133 mgr.registerChecker<CFGDumper>();
141 class CallGraphViewer :
public Checker< check::ASTDecl<TranslationUnitDecl> > {
144 BugReporter &BR)
const {
152 void ento::registerCallGraphViewer(CheckerManager &mgr) {
153 mgr.registerChecker<CallGraphViewer>();
161 class CallGraphDumper :
public Checker< check::ASTDecl<TranslationUnitDecl> > {
164 BugReporter &BR)
const {
172 void ento::registerCallGraphDumper(CheckerManager &mgr) {
173 mgr.registerChecker<CallGraphDumper>();
182 class ConfigDumper :
public Checker< check::EndOfTranslationUnit > {
185 static int compareEntry(
const Table::MapEntryTy *
const *LHS,
186 const Table::MapEntryTy *
const *RHS) {
187 return (*LHS)->getKey().compare((*RHS)->getKey());
192 AnalysisManager& mgr,
193 BugReporter &BR)
const {
194 const Table &Config = mgr.options.Config;
197 for (Table::const_iterator I = Config.begin(), E = Config.end(); I != E;
200 llvm::array_pod_sort(Keys.begin(), Keys.end(), compareEntry);
202 llvm::errs() <<
"[config]\n";
203 for (
unsigned I = 0, E = Keys.size(); I != E; ++I)
204 llvm::errs() << Keys[I]->getKey() <<
" = " 205 << (Keys[I]->second.empty() ?
"\"\"" : Keys[I]->second)
208 llvm::errs() <<
"[stats]\n" <<
"num-entries = " << Keys.size() <<
'\n';
213 void ento::registerConfigDumper(CheckerManager &mgr) {
214 mgr.registerChecker<ConfigDumper>();
222 class ExplodedGraphViewer :
public Checker< check::EndAnalysis > {
224 ExplodedGraphViewer() {}
225 void checkEndAnalysis(ExplodedGraph &G, BugReporter &B,ExprEngine &Eng)
const {
232 void ento::registerExplodedGraphViewer(CheckerManager &mgr) {
233 mgr.registerChecker<ExplodedGraphViewer>();
The AST-based call graph.
void dump()
This method dumps immediate dominators for each block, mainly used for debug purposes.
Decl - This represents one declaration (or definition), e.g.
Describes how types, statements, expressions, and declarations should be printed. ...
unsigned TerseOutput
Provide a 'terse' output.
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
AnalysisDeclContext contains the context data for the function or method under analysis.
Concrete subclass of DominatorTreeBase for Clang This class implements the dominators tree functional...
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
void buildDominatorTree(AnalysisDeclContext &AC)
This method builds the dominator tree for a given CFG The CFG information is passed via AnalysisDeclC...
llvm::StringMap< std::string > ConfigTable
Dataflow Directional Tag Classes.
void addToCallGraph(Decl *D)
Populate the call graph with the functions in the given declaration.
The top declaration context.