25 #include "llvm/Support/Process.h"
27 using namespace clang;
35 class DominatorsTreeDumper :
public Checker<check::ASTCodeBody> {
57 class LiveVariablesDumper :
public Checker<check::ASTCodeBody> {
77 class CFGViewer :
public Checker<check::ASTCodeBody> {
97 class CFGDumper :
public Checker<check::ASTCodeBody> {
103 Policy.PolishForDeclaration =
true;
104 D->print(llvm::errs(), Policy);
108 llvm::sys::Process::StandardErrHasColors());
123 class CallGraphViewer :
public Checker< check::ASTDecl<TranslationUnitDecl> > {
143 class CallGraphDumper :
public Checker< check::ASTDecl<TranslationUnitDecl> > {
164 class ConfigDumper :
public Checker< check::EndOfTranslationUnit > {
167 static int compareEntry(
const Table::MapEntryTy *
const *LHS,
168 const Table::MapEntryTy *
const *RHS) {
169 return (*LHS)->getKey().compare((*RHS)->getKey());
179 for (Table::const_iterator
I = Config.begin(),
E = Config.end();
I !=
E;
182 llvm::array_pod_sort(Keys.begin(), Keys.end(), compareEntry);
184 llvm::errs() <<
"[config]\n";
185 for (
unsigned I = 0,
E = Keys.size();
I !=
E; ++
I)
186 llvm::errs() << Keys[
I]->getKey() <<
" = " << Keys[
I]->second <<
'\n';
188 llvm::errs() <<
"[stats]\n" <<
"num-entries = " << Keys.size() <<
'\n';
202 class ExplodedGraphViewer :
public Checker< check::EndAnalysis > {
204 ExplodedGraphViewer() {}
221 class BugHashDumper :
public Checker<check::PostStmt<Stmt>> {
223 mutable std::unique_ptr<BugType> BT;
227 BT.reset(
new BugType(
this,
"Dump hash components",
"debug"));
236 std::string HashContent =
237 GetIssueString(SM, FL, getCheckName().getName(), BT->getCategory(),
240 C.
emitReport(llvm::make_unique<BugReport>(*BT, HashContent, N));
The AST-based call graph.
void dump()
This method dumps immediate dominators for each block, mainly used for debug purposes.
Describes how types, statements, expressions, and declarations should be printed. ...
unsigned TerseOutput
Provide a 'terse' output.
AnalysisDeclContext contains the context data for the function or method under analysis.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
detail::InMemoryDirectory::const_iterator I
Concrete subclass of DominatorTreeBase for Clang This class implements the dominators tree functional...
AnalysisDeclContext * getAnalysisDeclContext(const Decl *D)
CFG - 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...
CFG * getCFG(Decl const *D)
ExplodedNode * generateNonFatalErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
BugReporter is a utility class for generating PathDiagnostics for analysis.
CHECKER * registerChecker()
Used to register checkers.
ConfigTable Config
A key-value table of use-specified configuration values.
AnalyzerOptions & options
const Decl * getDecl() const
SourceManager & getSourceManager() override
detail::InMemoryDirectory::const_iterator E
const LangOptions & getLangOpts() const
std::string GetIssueString(const SourceManager &SM, FullSourceLoc &IssueLoc, llvm::StringRef CheckerName, llvm::StringRef BugType, const Decl *D, const LangOptions &LangOpts)
Get the string representation of issue hash.
llvm::StringMap< std::string > ConfigTable
SourceManager & getSourceManager()
A SourceLocation and its associated SourceManager.
void addToCallGraph(Decl *D)
Populate the call graph with the functions in the given declaration.
TranslationUnitDecl - The top declaration context.
const LangOptions & getLangOpts() const
void ViewGraph(bool trim=false)
Visualize the ExplodedGraph created by executing the simulation.
T * getAnalysis(Decl const *D)
This class handles loading and caching of source files into memory.
const LocationContext * getLocationContext() const