blob: 486b7f7feb1b3f48e449e6c8ce133d74dbd4f71f [file] [log] [blame]
Argyrios Kyrtzidis2d67b902011-02-17 21:39:39 +00001//==- DebugCheckers.cpp - Debugging Checkers ---------------------*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines a checkers that display debugging information.
11//
12//===----------------------------------------------------------------------===//
13
14#include "ClangSACheckers.h"
Argyrios Kyrtzidisec8605f2011-03-01 01:16:21 +000015#include "clang/StaticAnalyzer/Core/Checker.h"
Argyrios Kyrtzidis2d67b902011-02-17 21:39:39 +000016#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
17#include "clang/Analysis/Analyses/LiveVariables.h"
18
19using namespace clang;
20using namespace ento;
21
22//===----------------------------------------------------------------------===//
23// LiveVariablesDumper
24//===----------------------------------------------------------------------===//
25
26namespace {
Argyrios Kyrtzidisec8605f2011-03-01 01:16:21 +000027class LiveVariablesDumper : public Checker<check::ASTCodeBody> {
Argyrios Kyrtzidis2d67b902011-02-17 21:39:39 +000028public:
29 void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
30 BugReporter &BR) const {
31 if (LiveVariables* L = mgr.getLiveVariables(D)) {
32 L->dumpBlockLiveness(mgr.getSourceManager());
33 }
34 }
35};
36}
37
38void ento::registerLiveVariablesDumper(CheckerManager &mgr) {
39 mgr.registerChecker<LiveVariablesDumper>();
40}
41
42//===----------------------------------------------------------------------===//
43// CFGViewer
44//===----------------------------------------------------------------------===//
45
46namespace {
Argyrios Kyrtzidisec8605f2011-03-01 01:16:21 +000047class CFGViewer : public Checker<check::ASTCodeBody> {
Argyrios Kyrtzidis2d67b902011-02-17 21:39:39 +000048public:
49 void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
50 BugReporter &BR) const {
51 if (CFG *cfg = mgr.getCFG(D)) {
52 cfg->viewCFG(mgr.getLangOptions());
53 }
54 }
55};
56}
57
58void ento::registerCFGViewer(CheckerManager &mgr) {
59 mgr.registerChecker<CFGViewer>();
60}
61
62//===----------------------------------------------------------------------===//
63// CFGDumper
64//===----------------------------------------------------------------------===//
65
66namespace {
Argyrios Kyrtzidisec8605f2011-03-01 01:16:21 +000067class CFGDumper : public Checker<check::ASTCodeBody> {
Argyrios Kyrtzidis2d67b902011-02-17 21:39:39 +000068public:
69 void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
70 BugReporter &BR) const {
71 if (CFG *cfg = mgr.getCFG(D)) {
72 cfg->dump(mgr.getLangOptions());
73 }
74 }
75};
76}
77
78void ento::registerCFGDumper(CheckerManager &mgr) {
79 mgr.registerChecker<CFGDumper>();
80}