2011-02-18 05:39:39 +08:00
|
|
|
//==- DebugCheckers.cpp - Debugging Checkers ---------------------*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines a checkers that display debugging information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ClangSACheckers.h"
|
2011-03-01 09:16:21 +08:00
|
|
|
#include "clang/StaticAnalyzer/Core/Checker.h"
|
2011-02-18 05:39:39 +08:00
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
|
|
|
|
#include "clang/Analysis/Analyses/LiveVariables.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
using namespace ento;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// LiveVariablesDumper
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace {
|
2011-03-01 09:16:21 +08:00
|
|
|
class LiveVariablesDumper : public Checker<check::ASTCodeBody> {
|
2011-02-18 05:39:39 +08:00
|
|
|
public:
|
|
|
|
void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
|
|
|
|
BugReporter &BR) const {
|
|
|
|
if (LiveVariables* L = mgr.getLiveVariables(D)) {
|
|
|
|
L->dumpBlockLiveness(mgr.getSourceManager());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void ento::registerLiveVariablesDumper(CheckerManager &mgr) {
|
|
|
|
mgr.registerChecker<LiveVariablesDumper>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// CFGViewer
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace {
|
2011-03-01 09:16:21 +08:00
|
|
|
class CFGViewer : public Checker<check::ASTCodeBody> {
|
2011-02-18 05:39:39 +08:00
|
|
|
public:
|
|
|
|
void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
|
|
|
|
BugReporter &BR) const {
|
|
|
|
if (CFG *cfg = mgr.getCFG(D)) {
|
|
|
|
cfg->viewCFG(mgr.getLangOptions());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void ento::registerCFGViewer(CheckerManager &mgr) {
|
|
|
|
mgr.registerChecker<CFGViewer>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// CFGDumper
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace {
|
2011-03-01 09:16:21 +08:00
|
|
|
class CFGDumper : public Checker<check::ASTCodeBody> {
|
2011-02-18 05:39:39 +08:00
|
|
|
public:
|
|
|
|
void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
|
|
|
|
BugReporter &BR) const {
|
|
|
|
if (CFG *cfg = mgr.getCFG(D)) {
|
|
|
|
cfg->dump(mgr.getLangOptions());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void ento::registerCFGDumper(CheckerManager &mgr) {
|
|
|
|
mgr.registerChecker<CFGDumper>();
|
|
|
|
}
|