1 //==- DebugCheckers.cpp - Debugging Checkers ---------------------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a checkers that display debugging information.
12 //===----------------------------------------------------------------------===//
14 #include "ClangSACheckers.h"
15 #include "clang/StaticAnalyzer/Core/Checker.h"
16 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
17 #include "clang/Analysis/Analyses/LiveVariables.h"
19 using namespace clang;
22 //===----------------------------------------------------------------------===//
23 // LiveVariablesDumper
24 //===----------------------------------------------------------------------===//
27 class LiveVariablesDumper : public Checker<check::ASTCodeBody> {
29 void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
30 BugReporter &BR) const {
31 if (LiveVariables* L = mgr.getAnalysis<LiveVariables>(D)) {
32 L->dumpBlockLiveness(mgr.getSourceManager());
38 void ento::registerLiveVariablesDumper(CheckerManager &mgr) {
39 mgr.registerChecker<LiveVariablesDumper>();
42 //===----------------------------------------------------------------------===//
44 //===----------------------------------------------------------------------===//
47 class CFGViewer : public Checker<check::ASTCodeBody> {
49 void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
50 BugReporter &BR) const {
51 if (CFG *cfg = mgr.getCFG(D)) {
52 cfg->viewCFG(mgr.getLangOptions());
58 void ento::registerCFGViewer(CheckerManager &mgr) {
59 mgr.registerChecker<CFGViewer>();
62 //===----------------------------------------------------------------------===//
64 //===----------------------------------------------------------------------===//
67 class CFGDumper : public Checker<check::ASTCodeBody> {
69 void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
70 BugReporter &BR) const {
71 if (CFG *cfg = mgr.getCFG(D)) {
72 cfg->dump(mgr.getLangOptions());
78 void ento::registerCFGDumper(CheckerManager &mgr) {
79 mgr.registerChecker<CFGDumper>();